Changwang Zhang
Changwang Zhang

Reputation: 2483

How to add symbols representing point types in y labels

I want to add the symbols representing point types to y and y2 labels.

Here is the test code:

set key center top;
set ylabel "x"; 
set y2label "x^2";
plot x w lp pt 5 pi 5, x**2 w lp pt 7 pi 5 axes x1y2;

It gives:

enter image description here

I want the following:

enter image description here

Is there anyway to achieve this in Gnuplot?

I am using Gnuplot 4.6.5.

Thanks.

Upvotes: 1

Views: 689

Answers (1)

Christoph
Christoph

Reputation: 48390

One option would be to use set label ... point pt 7 lt 2 to place a dot somewhere. But that needs a lot of tweaking to get the correct position. And that position would need to be adapted manually depending on the font, font size, canvas size etc.

If only the point shape is important, you can use the respective glyph from the unicode block: geometric shapes. This is also from where I copied the symbols to the script. You must of course also use a font which includes the respective glyphs (e.g. Arial Unicode or DejaVu) and a proper terminal (e.g. pdfcairo, pngcairo, wxt are all fine):

set terminal pngcairo enhanced font "DejaVu" size 600,300
set output 'square-circle.png'
set key center top
set encoding utf8
set ylabel "x  {/*0.8 ■}"
set y2label "x^2  {/*0.8 ●}"
plot x w lp pt 5 pi 5, x**2 w lp pt 7 pi 5 axes x1y2;

Result with 4.6.5 is:

enter image description here

Upvotes: 1

Related Questions