Draw points and lines in gnuplot

≯℡__Kan透↙ 提交于 2019-12-11 04:23:59

问题


How is it possible with gnuplot to plot both isolated points and lines for the same input file?

I mean, once I have a file data.dat of this kind that defines two lines 1-2 and 3-4

x1 y1
x2 y2


x3 y3
x4 y4

I can plot the lines with

$> plot 'data.dat' w lp

but if I want to also add some isolated points to be displayed with gnuplot I would like to add to my data.dat file the following

x1 y1
x2 y2


x3 y3
x4 y4

x5 y5
x6 y6
x7 y7

obviously the points 5,6,7 are treated by gnuplot as points of a line. How can I draw 5,6,7 as isolated points?


回答1:


  • Organize your data in blocks. There should be exactly one empty line between two blocks:

    x1 y1
    x2 y2
    
    x3 y3
    x4 y4
    
    x5 y5
    x6 y6
    x7 y7
    
  • Use every to specify which blocks of the datafile should be plotted. The syntax of every is described here or in gnuplot (type help every)

  • In your case you can then do the following

    plot "data.txt" every :::0::1 with lp, "" every :::2::2 with points 
    



回答2:


if it's acceptable to plot point symbols for points 1..4, too, then just add empty lines after points 5 and 6 and say

plot "1.dat" with lines, "" with points

if not, I'd suggest writing the isolated points to a separate file.



来源:https://stackoverflow.com/questions/16435684/draw-points-and-lines-in-gnuplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!