Advice on boxes plot and setting xrange with a time axis

View: New views
6 Messages — Rating Filter:   Alert me  

Advice on boxes plot and setting xrange with a time axis

by Daniel Farrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have a plot boxes plot which is value of something at every month of  
the year. I want to change the xrange of the plot,

http://www.boyfarrell.com/forums/gnuplot/plot-bars.pdf

I want to be able to see all the box in the plot range (January is  
clipped and December is too large), this means I needs to set the  
xrange to be slightly larger than the data range i.e. from Jan-1 to Dec
+1. However, my xaxis is time in months numbers, 1,2,3 etc... I have  
tried a few methods of setting the xrange and the xtic placement my  
can't get it to work.

Here is the data and the plotting script, can anybody help?
http://www.boyfarrell.com/forums/gnuplot/bars.txt
http://www.boyfarrell.com/forums/gnuplot/plot-bars.txt

Regards,

Dan.




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Advice on boxes plot and setting xrange with a time axis

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

set timefmt "%m.%Y"
set xrange ["12.1999":"01.2001"]
set timefmt "%m"
plot 'bars.txt' using 1:2 title 'A'

explanation:
you can't set the xrange to 'december one year before' with
timefmt "%m" because there is no way to give the year, and
month numbers <= 0 are not allowed.

note:
gnuplot starts counting time from the 'beginning of epoch',
so if you have only month numbers in your datafile, it automatically
chooses year 2000.

Re: Advice on boxes plot and setting xrange with a time axis

by Daniel Farrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Thomas,

I have made the changes you suggested but it now clips on both sides!  
It this a bug?

Have a look here,

http://www.boyfarrell.com/forums/gnuplot/bars2.txt
http://www.boyfarrell.com/forums/gnuplot/plot-bars2.txt
http://www.boyfarrell.com/forums/gnuplot/plot-bars2.pdf

Regards,

Dan.

On 14 May 2008, at 19:17, Thomas Sefzick wrote:

>
> set timefmt "%m.%Y"
> set xrange ["12.1999":"01.2001"]
> set timefmt "%m"
> plot 'bars.txt' using 1:2 title 'A'
>
> explanation:
> you can't set the xrange to 'december one year before' with
> timefmt "%m" because there is no way to give the year, and
> month numbers <= 0 are not allowed.
>
> note:
> gnuplot starts counting time from the 'beginning of epoch',
> so if you have only month numbers in your datafile, it automatically
> chooses year 2000.
>
> --
> View this message in context: http://www.nabble.com/Advice-on-boxes-plot-and-setting-xrange-with-a-time-axis-tp17228309p17237732.html
> Sent from the Gnuplot - Dev mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gnuplot-beta mailing list
> gnuplot-beta@...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Advice on boxes plot and setting xrange with a time axis

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

you forgot to 'set xdata time'

your plotfile should read:

...
set xdata time
set timefmt "%m.%Y"
set xrange ["12.1999":"01.2001"]
plot 'bars2.txt' using 1:2 title 'A'

or

...
set xdata time
set timefmt "%m.%Y"
set xrange ["12.1999":"01.2001"]
set timefmt "%m"
plot 'bars.txt' using 1:2 title 'A'

you may adjust the xrange more precisely:

...
set timefmt "%d.%m.%Y"
set xrange ["15.12.1999":"18.12.2000"]
set timefmt "%m.%Y"
plot 'bars2.txt' using 1:2 title 'A'

Re: Advice on boxes plot and setting xrange with a time axis

by Daniel Farrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Right, thanks for that the range is correct. It is possible to set the  
time labels to be abbreviated month names?

Changing the second set timefmt "%m" doesn't make any difference?

Do I need to play with set xtics to do this?

Dan


On 15 May 2008, at 11:25, Thomas Sefzick wrote:

>
> you forgot to 'set xdata time'
>
> your plotfile should read:
>
> ...
> set xdata time
> set timefmt "%m.%Y"
> set xrange ["12.1999":"01.2001"]
> plot 'bars2.txt' using 1:2 title 'A'
>
> or
>
> ...
> set xdata time
> set timefmt "%m.%Y"
> set xrange ["12.1999":"01.2001"]
> set timefmt "%m"
> plot 'bars.txt' using 1:2 title 'A'
>
> you may adjust the xrange more precisely:
>
> ...
> set timefmt "%d.%m.%Y"
> set xrange ["15.12.1999":"18.12.2000"]
> set timefmt "%m.%Y"
> plot 'bars2.txt' using 1:2 title 'A'
>
> --
> View this message in context: http://www.nabble.com/Advice-on-boxes-plot-and-setting-xrange-with-a-time-axis-tp17228309p17250154.html
> Sent from the Gnuplot - Dev mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gnuplot-beta mailing list
> gnuplot-beta@...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: Advice on boxes plot and setting xrange with a time axis

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Right, thanks for that the range is correct. It is possible to set the  
> time labels to be abbreviated month names?

you had this command already in your first example:
set format x "%b"

> Changing the second set timefmt "%m" doesn't make any difference?
timefmt specifies how data are read in.

to get month-tics do:

set xtics 60*60*24*31
unset mxtics