Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #2726 > unrolled thread
| Started by | Colin Brough <Colin.Brough@blueyonder.co.uk> |
|---|---|
| First post | 2015-01-23 10:46 +0000 |
| Last post | 2015-01-26 17:41 +0000 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.graphics.apps.gnuplot
Histogram like plot with time xdata time... Colin Brough <Colin.Brough@blueyonder.co.uk> - 2015-01-23 10:46 +0000
Re: Histogram like plot with time xdata time... Karl <mail.kfr@gmx.net> - 2015-01-26 10:23 +0100
Re: Histogram like plot with time xdata time... Colin Brough <Colin.Brough@blueyonder.co.uk> - 2015-01-26 15:02 +0000
Re: Histogram like plot with time xdata time... Karl <mail.kfr@gmx.net> - 2015-01-26 17:50 +0100
Re: Histogram like plot with time xdata time... Colin Brough <Colin.Brough@blueyonder.co.uk> - 2015-01-26 17:41 +0000
| From | Colin Brough <Colin.Brough@blueyonder.co.uk> |
|---|---|
| Date | 2015-01-23 10:46 +0000 |
| Subject | Histogram like plot with time xdata time... |
| Message-ID | <UDpww.227584$4b6.175646@fx44.am4> |
Folks
I have three values for each month, in a data file formatted:
YYYY:MM D1 D2 D3
I am attempting to plot these in a histogram like format, three
boxes/columns adjacent to each other for each month. Histograms don't
quite work (unless I'm missing something), as there may be months with
no data and I'd like the X-axis to read as time. Its easy enough to do
with linespoints (plot file included), but with xdata set to 'time', I
am struggling...
With 'annual' data ("YYYY DD1 DD2 DD3") its easy enough, since you
can:
plot "data.dat" using ($1 - 0.25):($2 * 100) with boxes title "DD1",\
"data.dat" using 1:($3 * 10) with boxes title "DD2",\
"data.dat" using ($1 + 0.25):4 with boxes title "DD3"
Happy to told there is another way to come at this problem!
Thanks
Colin
#--------- GNUPLOT COMMAND FILE ---------
set title "Example"
set key left
set xdata time
set timefmt "%Y:%m"
set format x "%m/%Y"
plot [][0:] "data.dat" using 1:($2 * 100) with linespoints title "D1",\
"data.dat" using 1:($3 * 10) with linespoints title "D2",\
"data.dat" using 1:4 with linespoints title "D3"
pause -1 "Hit RETURN to continue"
#----------------------------------------
#---- EXAMPLE OF DATA TO BE PLOTTED -----
2013:1 4 80 868
2013:2 2 40 362
2013:3 3 60 489
2013:4 2 40 362
2013:5 2 40 390
2013:8 10 195 1775
2013:9 7 145 1423
2013:10 2 40 397
2013:11 1 20 229
2013:12 8 160 1610
2014:1 8 190 2227
2014:2 2 40 431
2014:3 2 35 361
2014:4 2 40 345
2014:5 1 20 196
2014:6 4 80 722
2014:7 9 180 1685
2014:8 15 300 3260
2014:9 19 380 4761
2014:10 2 40 452
2014:11 3 60 703
2014:12 3 60 673
2015:1 8 160 2052
#----------------------------------------
--
----------------------------------------------------------------------
Colin Brough Colin.Brough@blueyonder.invalid
(Replace .invalid with .co.uk to reply)
[toc] | [next] | [standalone]
| From | Karl <mail.kfr@gmx.net> |
|---|---|
| Date | 2015-01-26 10:23 +0100 |
| Message-ID | <ma512k$pho$1@news.rz.uni-karlsruhe.de> |
| In reply to | #2726 |
Am 23.01.2015 um 11:46 schrieb Colin Brough:
> Folks
>
> I have three values for each month, in a data file formatted:
>
> YYYY:MM D1 D2 D3
>
> I am attempting to plot these in a histogram like format, three
> boxes/columns adjacent to each other for each month. Histograms don't
> quite work (unless I'm missing something), as there may be months with
> no data and I'd like the X-axis to read as time. Its easy enough to do
> with linespoints (plot file included), but with xdata set to 'time', I
> am struggling...
>
> With 'annual' data ("YYYY DD1 DD2 DD3") its easy enough, since you
> can:
> plot "data.dat" using ($1 - 0.25):($2 * 100) with boxes title "DD1",\
> "data.dat" using 1:($3 * 10) with boxes title "DD2",\
> "data.dat" using ($1 + 0.25):4 with boxes title "DD3"
With time data, ($1-0.25) does not work, because 1 is not in years but
"seconds since 1970" (or 2000, depending on your gp version).
Something like ($1-0.25*30*24*3600) should do the trick by moving the
bar a quarter of a month to the left.
[toc] | [prev] | [next] | [standalone]
| From | Colin Brough <Colin.Brough@blueyonder.co.uk> |
|---|---|
| Date | 2015-01-26 15:02 +0000 |
| Message-ID | <XFsxw.405239$Ud7.363320@fx11.am4> |
| In reply to | #2728 |
On 26/01/15 09:23, Karl wrote:
> Am 23.01.2015 um 11:46 schrieb Colin Brough:
>> Folks
>>
>> I have three values for each month, in a data file formatted:
>>
>> YYYY:MM D1 D2 D3
>>
>> I am attempting to plot these in a histogram like format, three
>> boxes/columns adjacent to each other for each month. Histograms don't
>> quite work (unless I'm missing something), as there may be months with
>> no data and I'd like the X-axis to read as time. Its easy enough to do
>> with linespoints (plot file included), but with xdata set to 'time', I
>> am struggling...
>>
>> With 'annual' data ("YYYY DD1 DD2 DD3") its easy enough, since you
>> can:
>> plot "data.dat" using ($1 - 0.25):($2 * 100) with boxes title "DD1",\
>> "data.dat" using 1:($3 * 10) with boxes title "DD2",\
>> "data.dat" using ($1 + 0.25):4 with boxes title "DD3"
>
>
> With time data, ($1-0.25) does not work, because 1 is not in years but
> "seconds since 1970" (or 2000, depending on your gp version).
>
> Something like ($1-0.25*30*24*3600) should do the trick by moving the
> bar a quarter of a month to the left.
That's what I thought too, but that doesn't seem to work as expected:
plot [][0:] "data.dat" using 1:($2 * 100) with boxes title "Workouts
(x100)",\
"data.dat" using ($1 - 648000):($3 * 10) with boxes title "Time (x10)",\
"data.dat" using ($1 + 648000):4 with boxes title "Calories"
This produces a plot that looks like this:
http://www.colinbrough.pwp.blueyonder.co.uk/2015_01_26_TimeBarChart.png
The blue and green columns at 01/2000 come from the the ($1 - 648000)
and ($1 + 648000) plots... (Time and Calories). The red (Workouts) is
what I'm expecting...
For the sake of completeness, I'm running gnuplot 4.6 patchlevel 4 on
Ubuntu 14.04.1 LTS.
Cheers
Colin
--
----------------------------------------------------------------------
Colin Brough Colin.Brough@blueyonder.invalid
(Replace .invalid with .co.uk to reply)
[toc] | [prev] | [next] | [standalone]
| From | Karl <mail.kfr@gmx.net> |
|---|---|
| Date | 2015-01-26 17:50 +0100 |
| Message-ID | <ma5r82$7ui$1@news.rz.uni-karlsruhe.de> |
| In reply to | #2729 |
Am 26.01.2015 um 16:02 schrieb Colin Brough:
> On 26/01/15 09:23, Karl wrote:
>> Am 23.01.2015 um 11:46 schrieb Colin Brough:
>>> Folks
>>>
>>> I have three values for each month, in a data file formatted:
>>>
>>> YYYY:MM D1 D2 D3
>>>
>>> I am attempting to plot these in a histogram like format, three
>>> boxes/columns adjacent to each other for each month. Histograms don't
>>> quite work (unless I'm missing something), as there may be months with
>>> no data and I'd like the X-axis to read as time. Its easy enough to do
>>> with linespoints (plot file included), but with xdata set to 'time', I
>>> am struggling...
>>>
>>> With 'annual' data ("YYYY DD1 DD2 DD3") its easy enough, since you
>>> can:
>>> plot "data.dat" using ($1 - 0.25):($2 * 100) with boxes title
>>> "DD1",\
>>> "data.dat" using 1:($3 * 10) with boxes title "DD2",\
>>> "data.dat" using ($1 + 0.25):4 with boxes title "DD3"
>>
>>
>> With time data, ($1-0.25) does not work, because 1 is not in years but
>> "seconds since 1970" (or 2000, depending on your gp version).
>>
>> Something like ($1-0.25*30*24*3600) should do the trick by moving the
>> bar a quarter of a month to the left.
>
> That's what I thought too, but that doesn't seem to work as expected:
>
> plot [][0:] "data.dat" using 1:($2 * 100) with boxes title "Workouts
> (x100)",\
> "data.dat" using ($1 - 648000):($3 * 10) with boxes title "Time
> (x10)",\
> "data.dat" using ($1 + 648000):4 with boxes title "Calories"
>
> This produces a plot that looks like this:
>
> http://www.colinbrough.pwp.blueyonder.co.uk/2015_01_26_TimeBarChart.png
>
> The blue and green columns at 01/2000 come from the the ($1 - 648000)
> and ($1 + 648000) plots... (Time and Calories). The red (Workouts) is
> what I'm expecting...
>
> For the sake of completeness, I'm running gnuplot 4.6 patchlevel 4 on
> Ubuntu 14.04.1 LTS.
"$1" seems to not use the time format. You should be able to work around
that by using (timecolumn(1)+- 648000)) instead of just ($1+- 648000), i
think. Looks like an old bug.
You can give the boxes a width by "using 1:($2*100):(648000)", btw.
Karl
[toc] | [prev] | [next] | [standalone]
| From | Colin Brough <Colin.Brough@blueyonder.co.uk> |
|---|---|
| Date | 2015-01-26 17:41 +0000 |
| Message-ID | <Q_uxw.317311$QY7.137526@fx21.am4> |
| In reply to | #2730 |
On 26/01/15 16:50, Karl wrote:
> Am 26.01.2015 um 16:02 schrieb Colin Brough:
>> On 26/01/15 09:23, Karl wrote:
>>> Am 23.01.2015 um 11:46 schrieb Colin Brough:
>>>> Folks
>>>>
>>>> I have three values for each month, in a data file formatted:
>>>>
>>>> YYYY:MM D1 D2 D3
>>>>
>>>> I am attempting to plot these in a histogram like format, three
>>>> boxes/columns adjacent to each other for each month. Histograms don't
>>>> quite work (unless I'm missing something), as there may be months with
>>>> no data and I'd like the X-axis to read as time. Its easy enough to do
>>>> with linespoints (plot file included), but with xdata set to 'time', I
>>>> am struggling...
>>>>
>>>> With 'annual' data ("YYYY DD1 DD2 DD3") its easy enough, since you
>>>> can:
>>>> plot "data.dat" using ($1 - 0.25):($2 * 100) with boxes title
>>>> "DD1",\
>>>> "data.dat" using 1:($3 * 10) with boxes title "DD2",\
>>>> "data.dat" using ($1 + 0.25):4 with boxes title "DD3"
>>>
>>>
>>> With time data, ($1-0.25) does not work, because 1 is not in years but
>>> "seconds since 1970" (or 2000, depending on your gp version).
>>>
>>> Something like ($1-0.25*30*24*3600) should do the trick by moving the
>>> bar a quarter of a month to the left.
>>
>> That's what I thought too, but that doesn't seem to work as expected:
>>
>> plot [][0:] "data.dat" using 1:($2 * 100) with boxes title "Workouts
>> (x100)",\
>> "data.dat" using ($1 - 648000):($3 * 10) with boxes title "Time
>> (x10)",\
>> "data.dat" using ($1 + 648000):4 with boxes title "Calories"
>>
>> This produces a plot that looks like this:
>>
>> http://www.colinbrough.pwp.blueyonder.co.uk/2015_01_26_TimeBarChart.png
>>
>> The blue and green columns at 01/2000 come from the the ($1 - 648000)
>> and ($1 + 648000) plots... (Time and Calories). The red (Workouts) is
>> what I'm expecting...
>>
>> For the sake of completeness, I'm running gnuplot 4.6 patchlevel 4 on
>> Ubuntu 14.04.1 LTS.
>
> "$1" seems to not use the time format. You should be able to work around
> that by using (timecolumn(1)+- 648000)) instead of just ($1+- 648000), i
> think. Looks like an old bug.
>
> You can give the boxes a width by "using 1:($2*100):(648000)", btw.
Thanks, that's working fine now. Hadn't come across "timecolumn" before.
Was using 'set boxwidth XX' for the width of the boxes, but thanks for
that tip too...
Cheers
Colin
--
----------------------------------------------------------------------
Colin Brough Colin.Brough@blueyonder.invalid
(Replace .invalid with .co.uk to reply)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.graphics.apps.gnuplot
csiph-web