|
From: DavidH56 <dlh...@co...> - 2011-08-28 22:43:16
|
Cycle plots are useful in my work, and I'd like to know if it possible to create cycle plots in gnuplot. Naomi Robbins discusses cycle plots in her book Creating More Effective Graphs as well as in this article: http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf Cycle plots can be generated in R using the "monthplot" command. If cycle plots can't be created in gnuplot, is there a way to make a feature request? Thanks, David -- View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32276901.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Thomas S. <t.s...@fz...> - 2011-08-18 14:15:51
|
assuming that your data have the following format ... 2014-01-01 169 2014-02-01 170 2014-03-01 171 2014-04-01 172 ... and that there are no gaps in the data and that there is one value per month in every year, the following script may serve as an example how such a cycle plot may be produced: reset # number of entries per month (i.e. number of years) n=0 # number of months m=12 # although x-data are dates, we do the conversion into # 'seconds since the beginning of the epoch' by our own, # so we *don't* set xdata #set xdata time # but 'timefmt' we need for using 'timecolumn()' set timefmt "%Y-%m-%d" # dummy plot to determine the value of 'n' set table plot for [i=0:m-1] "datafilename" \ using ($0>n?n=$0:0 , $0):2 every 12::i unset table print n plot for [i=0:m-1] "datafilename" \ using (tm_mon(timecolumn(1))+$0+i*n):2 \ every m::i \ with linespoints DavidH56 wrote: > > Cycle plots are useful in my work, and I'd like to know if it possible to > create cycle plots in gnuplot. > > Naomi Robbins discusses cycle plots in her book Creating More Effective > Graphs as well as in this article: > > http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf > > Cycle plots can be generated in R using the "monthplot" command. If cycle > plots can't be created in gnuplot, is there a way to make a feature > request? > > Thanks, > > David > > -- View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32287405.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Thomas S. <t.s...@fz...> - 2011-08-24 19:14:36
|
meanwhile i improved my script adding monthnames at the
x-axis and horizontal lines. here it is:
reset
set macros
# number of months
m=12
# although x-data are dates, we do the conversion into
# 'seconds since the beginning of the epoch' by our own,
# so we *don't* set xdata
#set xdata time
# but 'timefmt' we need for using 'timecolumn()'
set timefmt "%Y-%m-%d"
set table
# number of entries per month (i.e. number of years)
n=0
# dummy plot to determine the value of 'n'
plot for [i=0:m-1] "datafilename" \
using ($0>n?n=$0:0 , $0):2 every m::i
print n
# calculate the averages of y-values belonging together and
# generate the horizontal lines
do for [i=0:m-1] {
sum=0
plot "datafilename" using 0:(sum=sum+$2 , $2) every m::i
av=sum/n
x=i*(n+1)
set arrow i+1 from x,av to x+n,av nohead lt 1 lc rgb "black"
}
unset table
# generate the xtics
mn="JanFebMarAprMayJunJulAugSepOctNovDec"
temp="set xtics ("
do for [i=0:m-1] {
if (i>0) {temp=temp.","}
# temp=temp.sprintf("\"%d\" %d",i+1,int(n/2)+i*(n+1))
temp=temp.sprintf("\"%s\" %d",substr(mn,3*i+1,3*i+3),n/2+i*(n+1))
}
temp=temp.")"
@temp
# and now the final plot
plot for [i=0:m-1] "datafilename" \
using (tm_mon(timecolumn(1))+$0+i*n):2 \
every m::i \
with linespoints \
lt 7 lc rgb "black"
DavidH56 wrote:
>
> Thomas,
>
> Thank you, your code worked great, it's exactly what I needed. I've been
> struggling with this problem for a while.
>
> I changed the timefmt in my script to "%m-%d-%Y" to match my data and I
> used set nokey to turn off the legend.
>
> The only minor problem I have is with the x axis. The x axis values run
> from 0 to 80 in increments of 10 units. The first plot, which is all of
> the January values, is flush left with an x value of zero, and the x
> values get out of kilter with December falling at approximately 70.
>
> Any thoughts?
>
> Thanks again,
>
> David
>
>
>
> Thomas Sefzick wrote:
>>
>> assuming that your data have the following format
>>
>> ...
>> 2014-01-01 169
>> 2014-02-01 170
>> 2014-03-01 171
>> 2014-04-01 172
>> ...
>>
>> and that there are no gaps in the data and that there is one value
>> per month in every year, the following script may serve as an example
>> how such a cycle plot may be produced:
>>
>> reset
>>
>> # number of entries per month (i.e. number of years)
>> n=0
>> # number of months
>> m=12
>>
>> # although x-data are dates, we do the conversion into
>> # 'seconds since the beginning of the epoch' by our own,
>> # so we *don't* set xdata
>> #set xdata time
>> # but 'timefmt' we need for using 'timecolumn()'
>> set timefmt "%Y-%m-%d"
>>
>> # dummy plot to determine the value of 'n'
>> set table
>> plot for [i=0:m-1] "datafilename" \
>> using ($0>n?n=$0:0 , $0):2 every 12::i
>> unset table
>> print n
>>
>> plot for [i=0:m-1] "datafilename" \
>> using (tm_mon(timecolumn(1))+$0+i*n):2 \
>> every m::i \
>> with linespoints
>>
>>
>>
>> DavidH56 wrote:
>>>
>>> Cycle plots are useful in my work, and I'd like to know if it possible
>>> to create cycle plots in gnuplot.
>>>
>>> Naomi Robbins discusses cycle plots in her book Creating More Effective
>>> Graphs as well as in this article:
>>>
>>> http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf
>>>
>>> Cycle plots can be generated in R using the "monthplot" command. If
>>> cycle plots can't be created in gnuplot, is there a way to make a
>>> feature request?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32329039.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: DavidH56 <dlh...@co...> - 2011-08-26 04:07:55
|
Hi Thomas,
I'm getting this msg with the latest script:
gnuplot> do for [i=0:m-1] {
^
"cycle4a.txt", line 15: invalid complex constant
Here's the script I'm using; my file is "Generation Data.txt" and I want to
plot column 17. I made minor changes to the lines preceded with "*" (I
removed comments for brevity):
reset
set macros
m=12
* set timefmt "%m-%d-%Y"
set table
n=0
* plot for [i=0:m-1] "Generation Data.txt" \
* using ($0>n?n=$0:0 , $0):17 every m::i
print n
do for [i=0:m-1] {
sum=0
* plot "Generation Data.txt" using 0:(sum=sum+$2 , $2) every m::i
av=sum/n
x=i*(n+1)
set arrow i+1 from x,av to x+n,av nohead lt 1 lc rgb "black"
}
unset table
mn="JanFebMarAprMayJunJulAugSepOctNovDec"
temp="set xtics ("
do for [i=0:m-1] {
if (i>0) {temp=temp.","}
temp=temp.sprintf("\"%s\" %d",substr(mn,3*i+1,3*i+3),n/2+i*(n+1))
}
temp=temp.")"
@temp
# and now the final plot
*plot for [i=0:m-1] "Generation Data.txt" \
* using (tm_mon(timecolumn(1))+$0+i*n):17 \
every m::i \
with linespoints \
lt 7 lc rgb "black"
--
View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32339219.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Thomas S. <t.s...@fz...> - 2011-08-26 09:35:09
|
sorry, i didn't mention that the script works with the
development version of gnuplot only.
curly braces don't work for the actual version of gnuplot.
DavidH56 wrote:
>
> Hi Thomas,
>
> I'm getting this msg with the latest script:
>
> gnuplot> do for [i=0:m-1] {
>
> ^
>
> "cycle4a.txt", line 15: invalid complex constant
>
> Here's the script I'm using; my file is "Generation Data.txt" and I want
> to plot column 17. I made minor changes to the lines preceded with "*" (I
> removed comments for brevity):
>
> reset
> set macros
>
> m=12
>
> * set timefmt "%m-%d-%Y"
>
> set table
>
> n=0
> * plot for [i=0:m-1] "Generation Data.txt" \
> * using ($0>n?n=$0:0 , $0):17 every m::i
> print n
>
> do for [i=0:m-1] {
> sum=0
> * plot "Generation Data.txt" using 0:(sum=sum+$2 , $2) every m::i
> av=sum/n
> x=i*(n+1)
> set arrow i+1 from x,av to x+n,av nohead lt 1 lc rgb "black"
> }
>
> unset table
>
> mn="JanFebMarAprMayJunJulAugSepOctNovDec"
> temp="set xtics ("
> do for [i=0:m-1] {
> if (i>0) {temp=temp.","}
> temp=temp.sprintf("\"%s\" %d",substr(mn,3*i+1,3*i+3),n/2+i*(n+1))
> }
> temp=temp.")"
> @temp
>
> # and now the final plot
> *plot for [i=0:m-1] "Generation Data.txt" \
> * using (tm_mon(timecolumn(1))+$0+i*n):17 \
> every m::i \
> with linespoints \
> lt 7 lc rgb "black"
>
>
>
--
View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32340517.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Thomas S. <t.s...@fz...> - 2011-08-26 10:08:07
|
for version 4.4 of gnuplot replace the two block containing the 'do'
commands:
...
set table
# number of entries per month (i.e. number of years)
n=0
# dummy plot to determine the value of 'n'
plot for [i=0:m-1] "datafilename" \
using ($0>n?n=$0:0 , $0):2 every m::i
print n
# calculate the averages of y-values belonging together and
# generate the horizontal lines
temp=""
plot for [i=0:m-1] "datafilename" \
using ( \
$0==0?sum=$2:sum=sum+$2 , \
$0==(n-1)?av=sum/n:0 , \
$0==(n-1)?x=i*(n+1):0 , \
$0==(n-1)?temp=temp.";set arrow ".sprintf("%d",i+1)." from
".sprintf("%d",x).",".sprintf("%d",av)." to
".sprintf("%d",x+n).",".sprintf("%d",av)." nohead lt 1 lc rgb 'black'":0 , \
$0 \
):2 every m::i
@temp
# generate the xtics
mn="JanFebMarAprMayJunJulAugSepOctNovDec"
temp="set xtics ("
plot for [i=0:m-1] "datafilename" \
using ( \
i>0?temp=temp.",":0 , \
temp=temp.sprintf("\"%s\" %d",substr(mn,3*i+1,3*i+3),n/2+i*(n+1)) , \
$0 \
):2 every 1::0::0
temp=temp.")"
@temp
unset table
# and now the final plot
...
DavidH56 wrote:
>
> Hi Thomas,
>
> I'm getting this msg with the latest script:
>
> gnuplot> do for [i=0:m-1] {
>
> ^
>
> "cycle4a.txt", line 15: invalid complex constant
>
> Here's the script I'm using; my file is "Generation Data.txt" and I want
> to plot column 17. I made minor changes to the lines preceded with "*" (I
> removed comments for brevity):
>
> reset
> set macros
>
> m=12
>
> * set timefmt "%m-%d-%Y"
>
> set table
>
> n=0
> * plot for [i=0:m-1] "Generation Data.txt" \
> * using ($0>n?n=$0:0 , $0):17 every m::i
> print n
>
> do for [i=0:m-1] {
> sum=0
> * plot "Generation Data.txt" using 0:(sum=sum+$2 , $2) every m::i
> av=sum/n
> x=i*(n+1)
> set arrow i+1 from x,av to x+n,av nohead lt 1 lc rgb "black"
> }
>
> unset table
>
> mn="JanFebMarAprMayJunJulAugSepOctNovDec"
> temp="set xtics ("
> do for [i=0:m-1] {
> if (i>0) {temp=temp.","}
> temp=temp.sprintf("\"%s\" %d",substr(mn,3*i+1,3*i+3),n/2+i*(n+1))
> }
> temp=temp.")"
> @temp
>
> # and now the final plot
> *plot for [i=0:m-1] "Generation Data.txt" \
> * using (tm_mon(timecolumn(1))+$0+i*n):17 \
> every m::i \
> with linespoints \
> lt 7 lc rgb "black"
>
>
>
--
View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32340682.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: DavidH56 <dlh...@co...> - 2011-08-28 22:43:05
|
Thomas, Thank you, your code worked great, it's exactly what I needed. I've been struggling with this problem for a while. I changed the timefmt in my script to "%m-%d-%Y" to match my data and I used set nokey to turn off the legend. The only minor problem I have is with the x axis. The x axis values run from 0 to 80 in increments of 10 units. The first plot, which is all of the January values, is flush left with an x value of zero, and the x values get out of kilter with December falling at approximately 70. Any thoughts? Thanks again, David Thomas Sefzick wrote: > > assuming that your data have the following format > > ... > 2014-01-01 169 > 2014-02-01 170 > 2014-03-01 171 > 2014-04-01 172 > ... > > and that there are no gaps in the data and that there is one value > per month in every year, the following script may serve as an example > how such a cycle plot may be produced: > > reset > > # number of entries per month (i.e. number of years) > n=0 > # number of months > m=12 > > # although x-data are dates, we do the conversion into > # 'seconds since the beginning of the epoch' by our own, > # so we *don't* set xdata > #set xdata time > # but 'timefmt' we need for using 'timecolumn()' > set timefmt "%Y-%m-%d" > > # dummy plot to determine the value of 'n' > set table > plot for [i=0:m-1] "datafilename" \ > using ($0>n?n=$0:0 , $0):2 every 12::i > unset table > print n > > plot for [i=0:m-1] "datafilename" \ > using (tm_mon(timecolumn(1))+$0+i*n):2 \ > every m::i \ > with linespoints > > > > DavidH56 wrote: >> >> Cycle plots are useful in my work, and I'd like to know if it possible to >> create cycle plots in gnuplot. >> >> Naomi Robbins discusses cycle plots in her book Creating More Effective >> Graphs as well as in this article: >> >> http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf >> >> Cycle plots can be generated in R using the "monthplot" command. If cycle >> plots can't be created in gnuplot, is there a way to make a feature >> request? >> >> Thanks, >> >> David >> >> > > -- View this message in context: http://old.nabble.com/Can-gnuplot-create-cycle-plots-%28also-called-month-plots%29--tp32276901p32323781.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Tait <gnu...@t4...> - 2011-08-29 14:36:32
|
> Cycle plots are useful in my work, and I'd like to know if it possible to > create cycle plots in gnuplot. > > Naomi Robbins discusses cycle plots in her book ... > as well as in this article: > http://www.perceptualedge.com/articles/guests/intro_to_cycle_plots.pdf As far as gnuplot is concerned, this is just a data plot, like any other. I made a quick example: http://www.plotshare.com/index.ws/plot/524664706. It uses linespoints for the line parts, and candlesticks to draw in the median line. On a stylistic note, I would not use a cycle plot. A graph should clearly and intuitively convey its message to the audience in the simplest way possible. I've yet to see a cycle plot that didn't complicate and obscure the message, when a simpler approach would have worked better. The article's claims notwithstanding, a cycle plot has the same weaknesses as the plots it purports to replace. By grouping the x-axis according to weekday, informtaion on trend through the week is difficult to read. (Try telling what happened in week three, for example: you must count one, two, three points from the left side of each grouping.) If the cycle plot had instead grouped by week (sub-grouping by day), the reader would have the opposite problem (what happened on Wednesdays?). Just put the independent variable on the x-axis, and the dependent on the y. If you have two points to make, then do it with two graphs. Don't try to squish both points awkwardly into one graph that makes neither point clearly. I'll illustrate using the example from your linked article. If the intent is to show trends by day for each week: put weeks 1-8 on a common x-axis, put the units sold for a given day on the y-axis, and stack the graphs for each day one on top of another. I just pulled this together quickly; it would need y-tics and some adjustment, but it might look like http://www.plotshare.com/index.ws/plot/785484084. If the intent is to convey relative mean and variance from day to day, then a box plot should be used to show average, variance, and outliers for each day, like http://www.plotshare.com/index.ws/plot/292462185. If the purpose was to compare week one to week four, then repeat the box plot using week number as the independent axis. Trying to do all at once pulls the audience's attention in multiple directions. |