How do I create a PlotTheme with larger fonts in the legend

Greetings,
I started using Julia a week ago and I’m documenting my transition from a background in MATLAB + Python to Julia at cooperrc.github.io.

I found myself stuck today when I tried to build my own theme and add it to PlotThemes.jl. Everything works great, except changing the legend_font_pointsize. It only has an effect if its included in the plot call.

Here is the theme I’m building:

_themes[:cooper] = PlotTheme(linewidth = 4,
                             markersize = 10,
                             fontfamily = "Sans",
                             titlefontsize = 24,
                             guidefontsize = 18,
                             tickfontsize = 18,
                             legend_font_pointsize = 18,
                            )

All the other fonts are 18 and 24, but the legend is still 8. I couldn’t find a different call to use in the subplot attributes

Any idea how to get the default legend font to be larger?

Hello and welcome to the community!

See the options here
https://docs.juliaplots.org/stable/generated/attributes_subplot/
search for legend_font

Example:

legend_font = Plots.Font("sans-serif", 8, :hcenter, :vcenter, 0.0, RGB{N0f8}(0.0,0.0,0.0))

Thanks! One follow-up though, it looks like the PlotThemes does not use Plots as a dependency. It only passes the PlotUtils values to the plot commands.

If I include Plots.Font, then I get an error or I can add using Plots to PlotThemse.jl. Then, I get a warning.

Is there a standard practice for specifying fonts via a call like Plots.theme(...)? Should I be using a different method for font specifications?

Wrapping this thread up:

I think the issue might have been how I was installing Julia. I tried three approaches:

  1. Install via conda issues
  2. Install via pacman issues
  3. install from julia github switch to v1.7.2 branch and make no issues

Now, when I call the theme

_themes[:cooper] = PlotTheme(linewidth = 4,
                             markersize = 10,
                             fontfamily = "Sans",
                             titlefontsize = 24,
                             guidefontsize = 18,
                             tickfontsize = 18,
                             legend_font_pointsize = 18,
                            )

Using Plots.theme(:cooper) I get a legend that has 18-point font just like the ticks and guides. It could have been a versioning issue on my end.