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

**URL:** <https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877>\
**Category:** Visualization\
**Tags:** question, plotting, plots\
**Created:** [February 22, 2022, 3:41am UTC](https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877 "2022-02-22T03:41:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cooperrc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cooperrc/32/34043_2.png) [@cooperrc](https://discourse.julialang.org/u/cooperrc)\
**Post date:** [February 22, 2022, 3:41am UTC](https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877/1 "2022-02-22T03:41:39Z")

</div>

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](https://cooperrc.github.io/Julia-learning/learning-julia.html).

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:

```julia
_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](https://docs.juliaplots.org/latest/generated/attributes_subplot/)

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

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [February 22, 2022, 8:23am UTC](https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877/2 "2022-02-22T08:23:22Z")

</div>

Hello and welcome to the community!

See the options here  
[https://docs.juliaplots.org/stable/generated/attributes\_subplot/](https://docs.juliaplots.org/stable/generated/attributes_subplot/)  
search for `legend_font`

Example:

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

```

---

<div class="post-metadata">

**Author:** ![cooperrc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cooperrc/32/34043_2.png) [@cooperrc](https://discourse.julialang.org/u/cooperrc)\
**Post date:** [February 22, 2022, 3:41pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877/3 "2022-02-22T15:41:03Z")

</div>

> [@baggepinnen](#):
>
> ```julia
> 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`](https://github.com/JuliaPlots/PlotThemes.jl) 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?

---

<div class="post-metadata">

**Author:** ![cooperrc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cooperrc/32/34043_2.png) [@cooperrc](https://discourse.julialang.org/u/cooperrc)\
**Post date:** [March 11, 2022, 8:45pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-plottheme-with-larger-fonts-in-the-legend/76877/4 "2022-03-11T20:45:07Z")

</div>

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](https://github.com/JuliaLang/julia) switch to v1.7.2 branch and `make` _no issues_

Now, when I call the theme

```julia
_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.
