|
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.
|