Search code examples
gnuplot

How to control colours for few starting n lines in gnuplut


I am having a two column file which contains data for n row. I want first few n starting lines with my required colours. Could you please tell me how to control the colours for first few lines in the below two column file for a gnuplot script?

https://wetransfer.com/downloads/5970dd1edd1a5a56999b4df3510751c620191108072534/1d6477

Solution

  • I guess this is a follow-up from your question here. To plot the first three sections in different color us column(-1). It is a pseudocolumn (see help pseudocolumns).

    Code:

    ### plot first three datasets with different color
    reset session
    
    myColor(n) = n==0 ? 0xff0000 : n==1 ? 0x00ff00 : n==2 ? 0x0000ff : 0xcccccc
    
    plot "plot_data.dat" u 1:2:(myColor(column(-1))) w l lc rgb var notitle
    ### end of code
    

    Result:

    enter image description here