Plots.jl: Default label size

Firstly, thanks for incorporating PGFPlotsX into Plots – it’s a really fantastic thing to have available.

Looking through the tikz generated when I savefig, I notice that most of the font sizes are hard-coded to 8pt by default.

I would like to incorporate the figure output by savefig into a latex document and, in an ideal world, I would like it to use whichever font size is being used in that document, rather than doing it’s own thing. I’m pretty sure that if I used PGFPlots / PGFPlotsX.jl manually, I could achieve this by not specifying the font size.

Is this something that can be achieved with the current implementation, or is it necessary to manually ensure that the font size in my plotting code is the same as my document?

1 Like

you can set the fontsizes via all the _fontsize keywords, e.g. titlefontsize, to match the fontsize in your document.
I’d suggest to do that via default so you don’t have to do it for every plot. Currently there is no way to not set the fontsize, but adding a method here to return an empty string for e.g. nothing could make sense.
Alternatively you could remove the fontsizes from the .tikz file via a regex replace.

I’d suggest to do that via default so you don’t have to do it for every plot. Currently there is no way to not set the fontsize, but adding a method here to return an empty string for e.g. nothing could make sense.

This works nicely! I just added the following method:

# Use default document font-size if nothing provided.
function Plots.pgfx_font(fontsize::Nothing, thickness_scaling = 1, font = "\\selectfont")
    return string("{", font, "}")
end

Any idea whether it would be worth me opening an issue about this on plots? Seems like a pretty common thing to want to do.

I think you can skip the issue and open a PR instead