2

I am using gnuplot 6.0 patchlevel 3 on Manjaro Linux, with the MWE below

reset
set encoding utf8
set terminal pdfcairo size 8in,8in font "STIX Two Math, 24" enhanced
set output "mwe-SO.pdf"
set polar
set angles radians
set grid linetype 3 linecolor "gray80"
set border linewidth 0.5
set samples 1000
set trange [0:10*pi]
set border linewidth 0.5
plot 1.0 * exp(0.1 * t) lw 5 title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}"
# set title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}" font "STIX Two Math, 24" enhanced
# show title

With the MWE as is, I get a title on the top right with math elements using the right fonts. enter image description here

However, if I un-comment the last two lines and comment out the segment from title onward on the third last line, I get the values for a, r and k instead of their symbols and the math font is lost.

enter image description here

My four questions are:

  1. How do I specify the location of the title with polar coordinates in the set title line?

  2. How may I get the symbols instead of the values if I use set title?

  3. How may I get the math font if I use set title?

  4. Fallback option: If I comment out the last two lines and restore the title portion of the thrd last line, how may I position it where I want?

Thanks.

P.S. The STIX two fonts are available on most Linux systems or from the GitHub repo.

1 Answer 1

3

This is an answer, but also asking for clarification. I guess you might be confused about different titles. Actually, there are at least 4 titles:

  • page title (in case of multiplots)

  • graph title

  • legend/key title

  • curve or keyentry title

By the way, settings or changes after the plot command will not appear in the plot. The plot command is usually the last command.

Check the following example and let us know which title you are actually talking about.

Script:

### different titles
reset session

set multiplot layout 2,2 title "Page title" font "STIX Two Math, 20"

    set title "Graph 1 title" font "STIX Two Math,16"
    set key out title "Legend/key title" font "STIX Two Math,14"
    plot sin(x)/x      title "1^{st} keyentry title", \
        sin(2*x)/(2*x) title "2^{nd} keyentry title"

    set title "Graph 2 title"
    plot cos(x)   title "1^{st} keyentry title", \
         cos(2*x) title "2^{nd} keyentry title"

    set title "Graph 3 title"
    plot sin(x)     title "1^{st} keyentry title", \
         sin(0.5*x) title "2^{nd} keyentry title"

    set title "Graph 4 title"
    plot cos(x)     title "1^{st} keyentry title", \
         cos(0.5*x) title "2^{nd} keyentry title"

unset multiplot
### end of script

Result:

enter image description here

Well, let me try to answer your four questions:

  1. check help title and help coordinates
set title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}" at polar pi/3, polar 0.5
  1. as long as your set title is after the plot command, it has no effect

  2. see 2.

  3. this is the keyentry title (check help key), i.e. a title together with the line (or point symbol) of the curve. If you have only one curve in your graph, it should be clear what you mean. So, instead of a keyentry title you could write it into the graph title. Anyway, you can position the key via the same coordinates like all labels.

Actually, titles are nothing else than special labels. In the example below, I added a set of labels at specific positions in the polar plot. I hope all this will answer your questions.

Script:

### titles/labels in polar coordinates
reset session

set polar
set size ratio -1
set border 0 polar
set grid polar lt -1 lc "dark-grey"
unset tics
set ttics 30
set rtics
set samples 1000
set trange[0:10*pi]

set title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}" font "STIX Two Math,20" at polar pi/3, polar 0.5

set for [i=1:12] label i sprintf("%d",i) at polar 7*pi/12-pi*i/6, polar 23 tc "blue"

set key at polar pi/2+0.2, polar 19 center font "STIX Two Math,12"

plot 1.0*exp(0.1*t) lc "red" lw 2 title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}"
### end of script

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you immensely. I had confused graph title with keyentry title and was not even aware of legend/key title. I was asking how to set the graph title but was doing it too late, after plot. I was not aware of how to use the help <topic> resource efficiently either. How does set size ratio -1 differ from set square, especially for polar plots? What does 0 do in set border 0 polar. What does polar pi/2+0.2 stand for? pi/2+0.2 equals 101.41°. Is that it? There is a need for specialized tutorials on, say, polar positioning, which I understood from your answer. Any links?
I executed your code and found out that for terminal pdfcairo, in the line set title "Logarithmic Spiral 𝑟 = 𝑎𝑒^{𝑘θ}" font "STIX Two Math,20" at polar pi/3, polar 0.5 the two polar coordinates do not seem to make any difference to the placement of the graph title. In any case, why would you use pi/3 for the angle and 0.5 for the radius? I would have used something like polar pi/2, polar 26 instead. Kindly clarify.
@chandra About ratio -1 check help size. Here, in a polar plot it doesn't make a difference to square. Check help border. 0 unsets the Kartesian borders. You can set angles degrees and give the coordinates in degrees (check help angles). polar pi/2+0.2 was just to shift it a bit more to the left. You are right: set title, apparenly at polar ... doesn't have any effect and the values are still remainders when I played around. I will check, but I assumed you can also place the graph title at any locations relative to different coordinate systems.
set size square is a synonym for set size ratio 1: from help size. Although I could not find it in the help, set border 0 does unset the Cartesian borders. Also, the title can only take on x, y offsets not coordinates. So. it has no effect.
@chandra I don't have any special links for tutorials, my primary source is help <keyword> or the PDF in the documentaion folder or the gnuplot home page with some demo graphs. Well, and of course Stackoverflow (tag gnuplot) where you can find a lot of non-obvious solutions and workarounds.
I have a question about drawing a straight y=x line superimposed on a polar plot for a spiral. I will ask it in a separate post and give a link here. Simple "kindergarten tutorials" on drawing lines between two points, overlaying plots, and juggling polar plots and straight lines on the same axes would really help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.