The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

carminat (49) [Avatar] Offline
#1
I am plotting two sets of data with dots in different colours, and I would like to tell the reader which is which.

Unfortunately gnuplot puts in the key a sample dot, which is hardly visible.

Can I change the sample (for instance choosing a square point rather than a dot)?
philipp.janert (286) [Avatar] Offline
#2
Solution 1:
If you are using lines (or linespts), you can increase the length of the sample in the key using "set key samplen".

Solution 2:
You make your own "key" using "set label" - and don't forget the "set label point" option!

Solution 3:
If you would like to take advantage of the services offered by the "set key" command (such as automatic alignment with the key, etc),
here is what I do:

plot [][0:1] "data" u 1:2 notitle, 2 title "Data" lt 1

Do you see what's going on?
For the data from the data file, I suppress the key entry using "notitle".
But then I add another "dataset" (just the constant value 2), which is outside the plot range, and therefore invisible -
but for this invisible dataset, I can choose whatever line or point type I want. A sample of this plot type shows up in
the key, and all I need to do is provide an appropriate label.
carminat (49) [Avatar] Offline
#3
philipp.janert wrote: [...]
Solution 3:
If you would like to take advantage of the services offered by the "set key" command (such as automatic alignment with the key, etc),
here is what I do:

plot [][0:1] "data" u 1:2 notitle, 2 title "Data" lt 1

Do you see what's going on? [...]


Thanks!
A little bit tricky, and yet it works.

However it's quite strange that this issue needs such clever workaround!
philipp.janert (286) [Avatar] Offline
#4
Actually, I think it's quite an elegant work-around...

And don't discard Solution 2 too quickly! In fact, I argue that the "classical key", off to one side, is not the best way to label a graph.
Well-placed individual labels, clearly associated with a line or data set on the graph, in many cases provide better service to the viewer.
carminat (49) [Avatar] Offline
#5
philipp.janert wrote:Actually, I think it's quite an elegant work-around...

And don't discard Solution 2 too quickly! In fact, I argue that the "classical key", off to one side, is not the best way to label a graph.
Well-placed individual labels, clearly associated with a line or data set on the graph, in many cases provide better service to the viewer.


Yes, solution 3 is elegant, indeed. What I meant to say is that it is a little bit awkward that such a problem (which does not seem so unusual) does not admit a more straightforward solution.

Anyway I also understand your argument in favour of Solution 2: probably it's the most reasonable choice for print quality plots.