Makie.jl v0.19 is a small minor release containing only two relevant changes.
First, there’s a breaking change: All occurrences of textsize
are now fontsize
, so search and replace that word and you will be good to go. The reason is that both of these had been in use for a long time, so we had to pick a moment to clean that up, which is now.
The other change is a new feature. With rich text, you can more easily plot text with more than one font, color or fontsize, as well as superscripts and subscripts. This also fixes the issue with non-matching superscripts in log axes, because these are now small normal glyphs and not special superscript glyphs, which many fonts don’t have (and there aren’t any unicode options for many glyphs you’d want to superscript or subscript, anyway). So now log tick styles will work regardless of font coverage of superscript glyphs. This will also be handy if you want to write simple math expressions in a font other than Computer Modern which is the hardcoded default of MathTexEngine.jl.
Below are a couple examples of rich text. Happy plotting!
using CairoMakie
f = Figure(fontsize = 30)
Label(
f[1, 1],
rich(
"H", subscript("2"), "O is the formula for ",
rich("water", color = :cornflowerblue, font = :italic)
)
)
str = "A BEAUTIFUL RAINBOW"
rainbow = cgrad(:rainbow, length(str), categorical = true)
fontsizes = 30 .+ 10 .* sin.(range(0, 3pi, length = length(str)))
rainbow_chars = map(enumerate(str)) do (i, c)
rich("$c", color = rainbow[i], fontsize = fontsizes[i])
end
Label(f[2, 1], rich(rainbow_chars...), font = :bold)
f
using CairoMakie
f = Figure(fontsize = 30)
Label(
f[1, 1],
rich(
"ITALIC",
superscript("Regular without x offset", font = :regular),
font = :italic
)
)
Label(
f[2, 1],
rich(
"ITALIC",
superscript("Regular with x offset", font = :regular, offset = (0.15, 0)),
font = :italic
)
)
f
Log ticks: