# Figure and font size when using \`Plots\`

**URL:** <https://discourse.julialang.org/t/figure-and-font-size-when-using-plots/117611>\
**Category:** Visualization\
**Tags:** plots, makie\
**Created:** [July 29, 2024, 8:02pm UTC](https://discourse.julialang.org/t/figure-and-font-size-when-using-plots/117611 "2024-07-29T20:02:56Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![cmichelenstrofer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmichelenstrofer/32/44392_2.png) [@cmichelenstrofer](https://discourse.julialang.org/u/cmichelenstrofer)\
**Post date:** [July 30, 2024, 3:55pm UTC](https://discourse.julialang.org/t/figure-and-font-size-when-using-plots/117611/8 "2024-07-30T15:55:09Z")

</div>

Ah, my mistake was using `pt_per_unit` in the wrong place… it should be used when saving the PDF. So it was using the default value (0.75). I can also use one of the default themes instead of specifying the font myself. Here is the solution that works.

```julia
using CairoMakie

x = 0:0.01:2π
y = cos.(x);

pt_per_unit = 1
figsizeinches(width, height) = (width, height) .* (72/pt_per_unit)

height = 2.5 # inches
width = 4.5 # inches
fontsize = 10

set_theme!(theme_latexfonts(); fontsize)

f = Figure(; size=figsizeinches(width, height))
ax = Axis(f[1,1], xlabel="x label", ylabel="y label")
lines!(ax, x, y, label="cosine", color=:tomato)
axislegend(position = :rb)

save("cosine.pdf", f; pt_per_unit)

```

As @p_f mentioned, maybe a better way than inches is basing the size of the figure on the `\textwidth` of the LaTeX document, and using `pt_per_unit=1`

---

_[View the full topic](https://discourse.julialang.org/t/figure-and-font-size-when-using-plots/117611)._
