Search code examples
gnuplot

How can I split my key so that one part is top right and the other part is top left?


since my last post I tried cleaning up my code a bit and am almost done with the plot. The only thing left to do is splitting the key of the first plot into two parts. One being the titles of the graphs and the other one being the time that data was captured. The title should go top left while the time should go top right.

The code:

set key top left title '0 s'´

set ylabel 'Konzentration'
set format y '%g'
set ytics border out nomirror 2
set mytics 2

plot 'data/paper_2_csv_a_0000.csv' using 3:1 axes x1y1 with lines ls 1 title 'Aktivator',\
     'data/paper_2_csv_h_0000.csv' using 3:1 axes x1y1 with lines ls 2 title 'Inhibitor'
;

produces the output

enter image description here

So how can I move the "Aktivator" and "Inhibitor" part to the left while leaving the "0 s" where it is right now?


Solution

  • There are several titles:

    • a title of a plot, check help title
    • a title of a legend/key, check help key, option title
    • a title of a multiplot, check help multiplot, option title

    I guess you want to separate the key title and move it to the other side. I guess that's not possible. Probably the easiest is to place a label. You place it e.g. at a position relative to the graph (here: 0.95,0.95) and the text alignment at that position is right. Check help label.

    Labels are persistent (e.g. in a multiplot environment), so don't forget to set unset label 1 or overwrite it with another title for the next multi(sub)plot.

    Script:

    ### place a label/title
    reset session
    
    set key top left
    set label 1 "0 s" at graph 0.95,0.95 font ",12" right
    
    set offsets 0,0,0.2,0.2
    
    plot sin(x), cos(x)
    ### end of script
    

    Result:

    enter image description here