How to plot several datasets with titles from one file in Gnuplot?

前端 未结 5 1857
心在旅途
心在旅途 2020-12-04 18:28

Assuming I have a file that looks like this:

\"p = 0.1\"
1 1
3 3
4 1


\"p = 0.2\"
1 3
2 2
5 2

Is it possible to make Gnuplot plot these tw

5条回答
  •  忘掉有多难
    2020-12-04 18:55

    With a slight modification of your data set (so that the titles are given as comments):

    #"p = 0.1"
    1 1
    3 3
    4 1
    
    
    #"p = 0.2"
    1 3
    2 2
    5 2
    

    You can plot these two data sets as separate lines like this:

    plot 'data.dat' i 0 t "p = 0.1", '' i 1 t "p = 0.2"
    

    The index (i for short) option to the plot command tells gnuplot to plot the ith data set. I can't find a way to get gnuplot to get the titles automatically from the header which is why I specified them manually with the title (t for short) option.

提交回复
热议问题