iomartin
iomartin

Reputation: 3199

How to add custom label to Gnuplot graph legend?

In a graph I'm making with gnuplot I draw some grey lines (set arrow command), which represent the physical boundaries of my experiment (i.e., walls)

I would like to know how I can add this information on the legend of the graph, so it says "Walls" and have a grey line next to it.

I thought about creating a new series that contained this information, but I was wondering if it's possible to explicitly add it.

Upvotes: 3

Views: 15863

Answers (3)

Peaceful
Peaceful

Reputation: 5450

One simple way is to make the name of the data file the legend which you want and then plot that data file.

Upvotes: 0

sdaau
sdaau

Reputation: 38649

Just wanted to note: since plotting a single line tended to mess up a graph of mine, a better solution for me was to plot a single point; but as found in Plotting single points « Gnuplotting, that is kinda difficult (especially if insertion at arbitrary plot legend/key position is needed) - unless redirection is used... This is what worked for me:

plot "filename" using 1:8 \
,\
... # more plot lines here
,\
"<echo '-1 -1'" lc rgb 'white' with points title '---' \
,\
... # more plot lines here

Upvotes: 0

andyras
andyras

Reputation: 15920

You can't add information directly to the legend. You can, however, either draw the legend explicitly, or plot a line which will not appear within the range of the plot, e.g.

plot [][0:1] 2 lc rgb 'gray' t 'Walls'

Or, if your x and y limits are already set:

...
[set x and y limits here]
...
plot 1e20 lc rgb 'gray' t 'Walls'

Upvotes: 6

Related Questions