Plots.jl treatment of strings/labels

Currently trying to remove PyPlot from some of my old code and trying to move to Plots.jl, and while I’m generally positively surprised about how quickly I’ve been able to convert some basic plots, some things still stump me.

The first issue I would assume is due to my own inability to properly read the documentation: I can’t seem to be able to figure out how to adjust the font of axis labels - on the attributes page I can find fonts for legends, axis ticks, titles etc but not for the axis labels?

A second related question is how strings are handled for different backends. Consider the following example:

using Plots

plotlyjs()

plot(Plots.fakedata(100), xlabel="This needs a<br>linebreak")

gr()

plot(Plots.fakedata(100), xlabel="This needs a<br>linebreak")

Given the different formatting of strings in the two backends (GR using “regular” string formatting, while PlotlyJS relies on html tags), the correct display of the plot depends on which backend the user has installed.

What is the accepted way of solving this in Plots.jl? I could think of simply setting the backend explicitly in the code, or checking for the active backend and then constructing the string appropriately, but both don’t seem optimal to me!

Concerning the axis label, the correct attribute is guidefont (or xguidefont for only x axis). It is documented in the table but admittedly a bit hard to find unless you know what to look for, it’d be interesting to hear if there are new ideas on how to improve that documentation page.

Concerning backends, while superficially they are interchangeable, digging deeper they are not. Especially if you do a lot of fine tuning to the plot, changing backend could require some adjusting. I personally simply chose one backend (GR) and stuck with it. GR is the default so you don’t need to do anything to set it.

1 Like