1

Now I am working on filecurves with 19 legends. The as default the graph have similar colors and not stacked correctly on the few bar on the right graph.

This is my data:

    a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s
201310  3   0   0   2   2   1   1   1   1   0   0   0   0   0   3   0   0   0   0
201401  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
201312  2   0   1   0   2   0   0   0   3   1   0   0   0   0   0   0   0   0   0
201305  3   1   0   4   9   0   2   4   1   4   1   1   2   0   2   0   0   0   0
201311  3   1   0   1   2   0   2   2   1   0   2   1   0   1   1   0   0   0   0
201306  5   0   1   2   4   0   1   0   1   0   0   0   0   0   3   0   0   1   0
201309  5   1   0   5   4   2   3   0   0   0   2   1   1   1   2   0   0   1   0
201308  3   1   0   2   6   1   1   1   0   1   0   1   0   0   0   0   0   0   0
201307  3   1   0   5   6   1   2   2   2   2   0   1   0   0   0   0   0   0   0
201303  6   0   0   1   1   2   1   2   0   0   0   0   0   0   0   0   0   3   0
201304  5   1   0   0   4   2   3   3   0   1   0   0   1   0   1   0   0   0   0
201302  3   0   2   2   2   0   1   1   0   0   0   1   1   1   0   0   0   1   0
201211  11  0   3   0   1   0   4   0   0   0   0   4   0   1   0   0   1   0   0
201301  4   0   0   0   3   2   2   2   0   2   0   1   1   0   0   0   0   0   0
201212  5   1   0   4   0   4   5   2   0   2   0   2   0   1   0   0   0   0   0
201210  5   0   0   7   0   2   0   1   0   0   0   0   0   1   0   0   0   0   0
201209  3   1   1   7   1   1   2   0   0   1   0   0   0   0   0   0   0   0   0
201208  9   4   2   0   2   6   4   0   1   1   0   1   0   1   0   0   0   0   1
201207  7   10  6   0   0   6   5   0   0   2   0   0   0   2   0   0   0   0   0
201206  3   5   3   1   0   4   6   0   1   1   2   0   0   2   0   1   0   0   0
201205  5   6   4   2   1   5   2   0   0   0   0   0   1   1   0   1   0   0   0
201204  6   6   4   3   3   2   2   0   0   3   0   0   0   0   0   0   0   0   0
201203  14  12  10  4   0   2   1   2   0   1   0   0   1   0   0   0   0   0   0
201202  17  12  8   5   2   5   3   2   0   6   3   4   0   1   0   1   1   0   0
201201  14  7   11  4   4   0   2   5   1   5   7   1   0   0   0   2   0   0   1
201112  9   5   3   3   1   0   0   0   0   1   2   6   0   0   0   1   0   0   0
201111  13  4   3   5   2   2   0   6   0   1   2   3   0   3   0   1   0   0   1
201110  15  2   9   10  2   2   2   3   1   5   0   2   0   0   0   2   1   0   1
201109  17  15  16  5   3   3   5   3   2   2   2   4   0   0   0   1   1   0   1
201108  6   5   3   0   8   5   6   1   2   2   2   1   3   0   0   0   0   0   0
201107  10  4   9   0   4   5   8   8   12  3   7   3   2   0   0   0   0   0   0
201101  0   0   0   0   5   3   1   0   0   1   2   0   2   0   0   0   2   0   1
201102  0   0   0   0   1   3   0   0   0   0   3   0   2   0   0   0   0   0   0
201106  1   1   0   1   3   5   4   1   1   0   0   0   2   0   0   0   1   0   0
201105  2   1   1   3   4   6   2   1   0   1   1   2   2   0   0   0   0   0   1
201104  1   1   0   1   1   3   1   1   0   0   1   0   1   0   0   0   0   0   0
201103  2   1   0   0   4   5   4   0   2   0   0   1   1   0   0   0   1   0   0

and this is my gnuplot file:

set terminal postscript eps color font 20
#set key below autotitle columnheader
set key above autotitle columnheader
set xtics font "Times-Roman, 15" 
set ytics font "Times-Roman, 15" 
set xdata time
set timefmt "%Y%m"
set format x "%b'%y"
set xrange ["201101":"201401"]
set grid

set output 'output.eps'
plot for [i=20:2:-1] \
"< awk 'NR==1 {print \"year\",$".(i-1)."} NR>=2 {for (i=2; i<=".i."; i++) \
{sum+= $i} {print $1, sum; sum=0} }' input.dat" \
using 1:2 with filledcurves x1 t column(2)

this is the output looks like: output

I tried to delete 4 latest months and it look's better, but I need to put all date in my graphs. Please you comments.. Thanks!

indi60
  • 867
  • 4
  • 17
  • 34

1 Answers1

1

Your data isn't monotonic in time. Usually you can use smooth unique but that doesn't work for me with filledcurves. But using sort after awk should do it. Try the following (cannot test it at the moment):

plot for [i=20:2:-1] "< awk ... input.dat | sort -r" using 1:2 with filledcurves x1 t column(2)
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • correct, to be honest I can't get the logic why I need sort here. but this is work for me... btw how about customs color of this? – indi60 Jul 08 '14 at 07:59
  • Because your dates in the first column aren't sorted. So with your data set you first have Oct'13, Jan'14, Dec'13, May'13 etc. This gives some twists in the plot. – Christoph Jul 08 '14 at 08:06
  • I set it now. Thanks for explanations @Christoph. – indi60 Jul 08 '14 at 08:10