I want to plot several lines. However I want all of them to have the same style and create a single entry in the legend.
When I use
splot '-' with lines
with these data
0.0 0.0 0.0
0.1 0.1 0.1
0.0 0.1 0.0
0.2 0.2 0.2
0.3 0.3 0.3
0.3 0.2 0.3
e
everything is as I expect. Also as expected, any style is applied to all the lines.
However if I try to add a title
splot '-' with lines title "myTitle"
an entry in the legend for each one is generated.
How can I have a single legend entry?
[Notice that I need two newlines between the data sets, because I want different lines and not a grid] [I am using Gnuplot Version 5.4 patchlevel 1]
Thanks!
Creation of duplicate key entries in this case was an unintended consequence of an intended change. See Issue #2380 duplicate titles in key. For the specific case here where the plot command requests a title by providing a quoted string, the old behavior will be restored in release 5.4.2 - you will only get a single entry in the key even though multiple data sets are plotted.
FYI - the change was introduced because it is now possible to generate a distinct title for each data set in the file. However it is not particularly useful to have multiple titles that are all the same. The intended use is illustrated by
plot 'file.dat' using 1:2 title sprintf("Data set %d", column(-2))
where column(-2)
returns the index number of this data set. In earlier gnuplot versions you would have to iterate explicitly over the index number
plot for [index=1:*] 'file.dat' using 1:2 title sprintf("Data set %d",index)