Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:gnuplot [2013/10/09 10:53]
cyril [Plot data from a file]
software:gnuplot [2024/04/19 09:54] (current)
cyril autotitle
Line 59: Line 59:
 set x2label "" set x2label ""
 set y2label "" set y2label ""
 +</code>
 +
 +  * Log scale.<code gnuplot>
 +set logscale x 2
 +set logscale y 10
 </code> </code>
  
Line 69: Line 74:
 set key left bottom set key left bottom
 set key 100,100 set key 100,100
 +</code>
 +
 +  * Automatic legend.<code gnuplot>
 +set key autotitle columnheader
 </code> </code>
  
Line 137: Line 146:
   * **every** Specifying lines to use (every 2 lines from line 50 to line 1050).<code gnuplot>   * **every** Specifying lines to use (every 2 lines from line 50 to line 1050).<code gnuplot>
 plot "data.dat" using 4:5 every 2::50::1050 plot "data.dat" using 4:5 every 2::50::1050
 +</code>
 +
 +  * **separator** Set the field separator:<code gnuplot>
 +set datafile separator ","
 </code> </code>
  
Line 159: Line 172:
 plot "data1.dat" using 4:5 lt rgb "red" plot "data1.dat" using 4:5 lt rgb "red"
 plot "data1.dat" using 4:5 lt rgb "#FF0000" plot "data1.dat" using 4:5 lt rgb "#FF0000"
 +</code>
 +
 +  * **palette** Colors as value.<code gnuplot>
 +set palette defined (0 "black", 1 "red")
 +plot "data1.dat" using 1:2:0 w p palette
 </code> </code>
  
Line 190: Line 208:
 </code> </code>
  
-  * **($1)** Arithmetics on columns.<code gnuplot>+  * **($1)** Arithmetics on columns data.<code gnuplot>
 plot "data1.dat" using 4:($5/2+14) plot "data1.dat" using 4:($5/2+14)
 # where $n means column n # where $n means column n
 +</code>
 +
 +  * **(column())** Arithmetics on columns indices.<code gnuplot>
 +plot i=1, "data1.dat" using 1:(column(i+1))
 </code> </code>
  
Line 203: Line 225:
  
 plot "gps.dat" using (rotation_x($3,$4)):(rotation_y($3,$4)) plot "gps.dat" using (rotation_x($3,$4)):(rotation_y($3,$4))
 +</code>
 +
 +  * **word()** Define array variables.<code gnuplot>
 +colors="red blue green"
 +print word(colors,3)
 </code> </code>
  
Line 214: Line 241:
 plot for [file in "run1.dat run2.dat run3.dat"] file using 1:2 plot for [file in "run1.dat run2.dat run3.dat"] file using 1:2
 </code><code gnuplot> </code><code gnuplot>
-plot for [i=1:3] run.dat using i+plot for [i=1:3] run.dat using i t sprintf("curve %s", columnheader(i))
 </code><code gnuplot> </code><code gnuplot>
 file(n) = sprintf("run_%d.dat",n) file(n) = sprintf("run_%d.dat",n)
Line 277: Line 304:
  
   * or anything else with shell commands...   * or anything else with shell commands...
 +
 +  * **fit** a function to data:<code gnuplot>
 +f(x) = a*x**2 + b*x + c
 +fit f(x) "file.dat" u 1:2 via a,b,c
 +plot "file.dat" u 1:2, f(x)
 +</code>
  
   * **sh** Passing arguments to a gnuplot script.   * **sh** Passing arguments to a gnuplot script.
Line 428: Line 461:
 </code> </code>
  
-  * Progressive display (but the plot is not really interactive anymore)<code gnuplot>+  * Progressive display (but the plot is not interactive anymore)<code gnuplot>
 plot "file.dat" u 1 plot "file.dat" u 1
-while(1) { replot ; pause 0.}+while(1) { replot ; pause 0.}
 </code> </code>
  
-  * Pausing and resuming the progressive display for interactivity (only works with x11 terminal).<code gnuplot>+  * Pausing and resuming the progressive display for interactivity (only works with x11 terminal if started in interactive gnuplot shell... for wxt terminal the event processing loop -- wxt_gui.cpp:wxt_waitforinput function -- is not called during the update loop, but ctrl-c in the shell stops the update loop and allows plot interactivity afterwards, contrary to x11 term...).<code gnuplot>
 set terminal x11 set terminal x11
 bind "c" "update=1-update ; while(update) { replot ; pause 0.1 }" bind "c" "update=1-update ; while(update) { replot ; pause 0.1 }"
 plot "file.dat" u 1 plot "file.dat" u 1
 update=1 update=1
-while(update) { replot ; pause 0.}+while(update) { replot ; pause 0.}
 </code> </code>
  
software/gnuplot.1381315980.txt.gz ยท Last modified: 2013/10/09 10:53 by cyril
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0