Line plot in GnuPlot where line color is a third column in my data file?

后端 未结 3 1288
陌清茗
陌清茗 2020-11-28 07:59

I have a datafile that looks like this:

1 1.0 0
2 1.5 0
3 0.0 1
4 1.2 2
5 1.0 1
6 1.1 1

where the first column is my X value, the second co

相关标签:
3条回答
  • 2020-11-28 08:30
    plot 'foo.dat' with lines linecolor variable
    

    or abbreviated:

    plot 'foo.dat' w l lc var
    
    0 讨论(0)
  • 2020-11-28 08:31

    This has been asked long ago, but i just had the same question. And the most suitable way to also get legend/title for "variable" colors, was:

    # set this to the range of your variable which you want to color-encode
    # or leave it out
    set cbrange [0:1]
    
    # define the palette to your liking
    set palette defined ( 0 "#B0B0B0", 0.333 "#FF0000", 0.666 "#0000FF", 1.0 "#000000" )
    
    # in this example, column 3 is mapped to the colors of the palette
    plot "data.txt" u 1:2:3 w l lc palette z
    

    (tested on gnuplot 4.6 patchlevel 4)

    0 讨论(0)
  • 2020-11-28 08:37

    This following works for me (gnuplot 4.4)

    plot "./file.dat" u 1:2:3 with lines  palette
    

    Hope this helps.

    When I ran your code gnuplot couldn't pass the "rgb" part.

    For an example of using the variable tag see the similar question: GNUPLOT: dot plot with data depending dot size

    with the useful examples found here: http://gnuplot.sourceforge.net/demo/pointsize.html

    All the best

    Tom

    0 讨论(0)
提交回复
热议问题