Two fonts in the same sentence - gnuplot

In gnuplot, how do I make labels consist of two parts, one of which is in regular text, and the other is in boldface? It's only easy to set a font for an entire sentence.

Using gnuplot 5 it is quite easy. In enhanced text mode, which is by default switched on, you can use the syntax {/:Bold ...} to select the boldface of whatever font is currently select. Likewise, using {/:Normal ...} and {/:Italic ...} selects normal or italic font styles:
set label 1 center at 0,0 '{/:Bold bold {/:Normal normal} {/:Italic bold italic}} {/:Italic italic}' font 'Linux Biolinum O,20'
plot x

Related

Introduce a box with special symbols in Gnuplot

I want to have a gnuplot with a box on the right top corner like the one below. My difficulties are both:
how to get \hat{Q} in a the legend?
how to add a box containing the titles?
set term cairolatex eps standalone size 3in,3in
set output 'Q.tex'
set key box opaque samplen 0.5
plot for [i=1:4] sinc(x)**i title sprintf('\tiny${\hat{Q}=%d}$',i) lw 2
The standalone keyword wraps the output in minimal LaTeX commands so that you can run latex Q directly. Omit this if you want to produce a LaTeX fragment for including in a larger document.
I show how to construct a formatted title that includes a LaTeX font size. Note that the format uses single quotes rather than double quotes.
This example uses cairolatex eps because you specifically asked about an eps file. Normallay I would use cairolatex png or cairolatex pdf and process afterwards with pdflatex rather than plain latex.
If you want to include your figure into LaTeX, you should use the terminal cairolatex, then you can include LaTeX code in your plots:
plot "your.data" title '$\hat{Q}=10$'
Concerning your second question, have a look at the manual concerning set key.

Strange behaviour in gnuplot for label with Arial font face in pdfcairo terminal

I am obtaining a strange behaviour on gnuplot 5.2.2 pdfcairo terminal with a label composed of several lines and attempted to be printed align to center. The label is the signature for my plots, it is composed of my name (first line), my institution (second line) and the date, obtained from time(0) and strftime.
In a multiplot script I noticed that the date (3rd line) was printed align to left while the other two line were printed align to center as intended. Then I placed the set label instruction before the first plot was called so that the label is printed two times. Then, in the first call, date was aligned to left but in the second call the date was aligned to center, as intended. Same happens if the align to right mode is intended. However if the strftime string is substituted by a regular string "foo" then alignment works fine.
This behaviour only happens if font is set to Arial and if the terminal is set to pdfcairo. If font is set to Ubuntu (or Times) or if the terminal is set to pngcairo then all calls print the label truly align to center.
A minimal workable example is:
set terminal pdfcairo enhanced color font "Arial,"
set output "prueba.pdf"
set multiplot layout 1,2
set colors podo
Cadena_firma="Martin-Olalla JM\nUniversidad de Sevilla\n".strftime("%Y/%m/%d",time(0))
set label 1 at screen 0.85,0.25 Cadena_firma noenhanced center font "Arial,10" tc rgb '#9d2235' front
set yrange [-2:2]
plot sin(x) lc 3
plot cos(x) lc 3
I attached the output, highlighting the weird printing of the date.
This is only happening in one of the computers I handle. It is easily solvable by changing the font. Nonetheless I am curious and it might be interesting for others.
There have been multiple reports of font problems that all appear to trace back to bad pango/cairo library versions. Some of the problems are OS-specific and some are font-specific. So there are probably multiple issues involved. Here are some tracker items:
https://gitlab.gnome.org/GNOME/pango/issues/422
and
https://sourceforge.net/p/gnuplot/bugs/2052/

How to place labels on top of the margin?

I am using gnuplot with epslatex terminal. I want to know how to put the
label on top of a margin, so that the part of margin under the label is invisible. In the figure I attached, the part of margin under the label
is still visible.
In principle you should be able to tell gnuplot to put your text labels into a box by using the set label ... front boxed, and the specify that the box should be opaque and white using something like set style textbox opaque noborder fillcolor rgb "white". However, this is not supported by all terminals, and epslatex seems to be one of those where this doesn't work.
However, in epslatex you can simply use latex commands to create a white background box around your label text:
set term epslatex standalone
set outp "test.tex"
set label "\\colorbox{white}{This is a label}" at 6.,0.5 front
plot sin(x)
set output
gives

GNUPlot color inversion

Since my eyes get less strained with dark windows, I'd like to set a dark background in my gnuplot terminal. Setting a dark square beneath the plot would be a solution, if only this would not affect readability (dark lines on dark background...).
I don't want to spend my day in finding color combinations, however by inverting the terminal color I would get exactly what I need: dark background and readable plots.
Does anyone know a command for inverting the terminal, or the name of an interactive terminal (supported by GNU/Linux) which supports color inversion?
Thanks in advance.
Many terminals (including png and wxt) have background option.
You can set dark background, for example:
set terminal wxt background '#00222222'
And then change border/axis color to something light, for example:
set style line 101 lc rgb '#808080' lt 1 lw 1
set border 3 front ls 101
I don't know about automatic 'color inversion', but this seems like a pretty good workaround. You can find some interesting information in Ease your plotting with config-snippets article.
See gnuplot-colorbrewer for some predefined color schemes.

gnuplot: subtitle with smaller fontsize

Does somebody know how you can insert a subtitle with a smaller fontsize in gnuplot?
Currently, the way I create a subtitle is by using \n in the title. Additionally, I would like the subtitle to have a smaller fontsize.
Thanks in advance.
This works for the postscript terminal at least (for some reason x11 didn't want to scale my font. Perhaps it is a bug...):
set term <whatever> enhanced
set output "<whatever.ext>"
set title "Big Title\n{/*0.5 subtitle}"
The {/*0.5} scales the fontsize to be half of the current active fontsize. You can also specify fontsizes explicitly:
set title "{/=20 Big} Medium {/=5 Small}"
Or you can change the font for a region of text:
set title "{/Helvetica foo} {/Symbol G}"
These forms can be combined to change the font and size in a particular region of text as well:
set title "This is a big gamma {/Symbol=20 G}"
For more information about enhanced text, see help enhanced.
You can use label. You have to experiment a bit with its proper placement by at:
set title "Big Title"
set label "Subtitle" at screen 0.5, 0.9 font "Arial,8"
plot sin(x)

Resources