Search code examples
gnuplot

Use default linecolor as textcolor


Gnuplot has some default color for lines.

How can I call those colors with textcolor? What are their name/identifier?

I try to do something like this:

set ylabel 'A' textcolor 'linecolor1'
set ylabel 'B' textcolor 'linecolor2'

I'm aware of this, but I want to avoid extracting the values by myself and call their identifier instead.


Solution

  • Check help colorspec. I guess you are looking for something like this:

    Code:

    ### linecolors as textcolors
    reset session
    
    set label 1 at graph 0.2, 0.6 "Linecolor 1" tc lt 1
    set label 2 at graph 0.2, 0.7 "Linecolor 2" tc lt 2
    set label 3 at graph 0.2, 0.8 "Linecolor 3" tc lt 3
    set label 4 at graph 0.2, 0.9 "Linecolor 4" tc lt 4
    set key top left
    plot x, 2*x, 3*x, 4*x
    
    ### end of code
    

    Result:

    enter image description here