Gnuplot conditional plotting -


i need use gnuplot plot wind direction values (y) against time (x) in 2d plot using lines , points. works fine if successive values close together. if values eg separated 250 degrees need have condition checks previous y value , not draw line joining 2 points. condition occurs when wind dir in 280 degrees 20 degrees sector , plots messy eg north wind. data time dependent cannot use polar plots except @ specific point in time. need show change in direction on time.

basically problem is:

plot y against x ; when (y2-y1)>= 180 break/erase line joining successive points can give me example of how this?

a sample data file is:

2014-06-16 16:00:00 0.000 990.081 0.001 0.001 0.001 0.001 0.002 0.001 11.868 308 002.54 292 004.46 00  2014-06-16 16:10:00 0.000 990.047 0.001 0.001 0.001 0.001 0.002 0.001 11.870 303 001.57 300 002.48 00  2014-06-16 16:20:00 0.000 990.014 0.001 0.001 0.001 0.001 0.002 0.001 11.961 334 001.04 314 002.07 00  2014-06-16 16:30:00 0.000 990.014 0.001 0.001 0.001 0.001 0.002 0.001 11.818 005 001.18 020 002.14 00  2014-06-16 16:40:00 0.000 990.014 0.001 0.001 0.001 0.001 0.002 0.001 11.725 332 001.14 337 002.26 00 

and want plot column 12 vs time.

you can insert filtering condition in using statement , use value of 1/0 if condition not fullfilled. in case point not connect others:

set timefmt '%y-%m-%d %h:%m:%s' set xdata time unset key  y1 = y2 = 0 plot 'data.dat' using 1:(y1 = y2, y2 = $12, ($0 == 0 || y2 - y1 < 180) ? $12 : 1/0) lines,\      'data.dat' using 1:12 points 

with data sample , gnuplot version 4.6.5 plot:

enter image description here

unfortunately, approach cannot categorize lines, points , line following 1/0 point aren't drawn.

a better approach use awk insert empty line when jump occurs. in 2d-plot points different data blocks (separated single new line) aren't connected:

set timefmt '%y-%m-%d %h:%m:%s' set xdata time unset key  plot '< awk ''{y1 = y2; y2 = $12; if (nr > 1 && y2 - y1 >= 180) printf("\n"); print}'' data.dat' using 1:12 linespoints 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -