Posted by: dbbrtdb | August 9, 2010

Gnuplot : line style, every

How do I plot a part of data in a file ?

To specify a range of the data to be plotted, use the every option in the plot command. To skip every two lines, say plot “test.dat” every 2

When the data file contains several data blocks those are separated by a single blank line, you can skip the data block by the every option. To skip every two block, try plot “test.dat” every :2

every I:J:K:L:M:N
I Line increment
J Data block increment
K The first line
L The first data block
M The last line
N The last data block
every 2 plot every 2 line
every ::3 plot from the 3-rd lines
every ::3::5 plot from the 3-rd to 5-th lines
every ::0::0 plot the first line only
every 2::::6 plot the 1,3,5,7-th lines
every :2 plot every 2 data block
every :::5::8 plot from 5-th to 8-th data blocks

Alternatively (if you are on the UNIX-like system), a part of your data file can be plotted by using the unix commands, “head” and “tail“.

gnuplot> plot "< head -10 test.dat" using 1:2 with lines
gnuplot> plot "< tail -3 test.dat" using 1:2 with lines
gnuplot> plot "< head -5 test.dat" using 1:2 with lines,\
>        plot "< tail -5 test.dat" using 1:2 with points

The first “plot” command says to plot the first 10 lines in the data file “test.dat”, and the second “plot” means to show the last 3 lines in the data file. The next lines are an example to draw a graph of the data file “test.dat” — the first 5 points are shown by lines, and the last 5 points are by symbols.

  • Thanks to the author of the this linkĀ  here

How do I make a figure with many kinds of lines ?

gnuplot> set term postscript eps enhanced
gnuplot> set linestyle 1 lt 1 lw 1
gnuplot> set linestyle 2 lt 2 lw 1
gnuplot> set linestyle 3 lt 3 lw 1
gnuplot> set linestyle 4 lt 6 lw 1
gnuplot> set linestyle 5 lt 1 lw 3
gnuplot> set linestyle 6 lt 2 lw 3
gnuplot> set linestyle 7 lt 3 lw 3
gnuplot> set linestyle 8 lt 6 lw 3
gnuplot> set xrange [-pi:pi]
gnuplot> plot sin(  x) w l ls 1, sin(2*x) w l ls 2, \
              sin(3*x) w l ls 3, sin(4*x) w l ls 4, \
              cos(  x) w l ls 5, cos(2*x) w l ls 6, \
              cos(3*x) w l ls 7, cos(4*x) w l ls 8
  • Thanks to the author of the this linkĀ  here
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.