Gnuplot provides a number of point styles to use in scatter plots, such as a cross, a star, a square, a circle etc. The available point types can be demonstrated by using the test
command.
However, for a specific application, I need different symbols, and I need legend entries that show these symbols.
In particular, I need more than four symbols that can be plotted both in outlined and in filled state (e. g. triangles pointing left or right, parallelograms or non-square rectangles).
There are a number of approaches to use other shapes (each with some requirements towards the terminal, e. g. unicode support):
set label '□' at 3,4
for each point, where □ can be replaced by any unicode character, such as ◁, ▶, ▭, ▮, etc.)plot ... with labels
and providing a unicode character as a labelThe problem with all of these approaches is that I can't get a proper legend (key) entry including the symbol.
I considered plotting the legend myself, but there are two reasons why I don't think that this is feasible:
using linespoints
for regular Gnuplot point types), which both have to be shown in the legend.I am generating the Gnuplot input files programmatically, so an approach that explicitly lists all points (like the set label
approach mentioned above), or that requires some calcuations, is OK.
This won't be an answer because I'm going to tell you to change your terminal ... I know...
There is no way to add user-defined point shape in gnuplot yet, but the PostScript terminal allows about 70 different : http://www.cp.cmc.osaka-u.ac.jp/~fumiko/tips/gnuplot_pt.jpg
In the following discussion, they state that there's no general mechanism to add user defined point type. And they come with the solution you gave in your question. https://groups.google.com/forum/?fromgroups=#!topic/comp.graphics.apps.gnuplot/in57UNxG2o0
I think a way to achieve your objective may be to
I'm afraid I will have to face the same problem, so let the world know if you find an easier solution :)
if anyone wants to mess with the postscritp route here is a simple example:
Each symbol is defined by name (See table in Pascali's answer) in the ps file as for example :
/BoxF {
....3 or 4 lines of terse code ...
} def
Replace with your own definition: This is a capital letter Pi.
/BoxF {
stroke gsave moveto % required, this finishes prior line and moves to point
0 30 rmoveto % nudge symbol to get it centered properly
/Symbol findfont 120 scalefont setfont (P) Cshow
grestore
} def
This simple example may need the numbers (font size) tweaked for different types of plots..
If you want to use fonts that aren't known by your postscript interpreter you need to manually include them.
Similar to Pascail's answer, you can also do this with SVG instead of Postscript.
SVG is based on XML and may or may not be easier to process than Postscript (using an XML library). It also supports unicode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With