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