Makie.jl
Makie.jl copied to clipboard
poor handling of LaTeX in x- and y-axis labels
:heart: Makie generally, but to include these plots in scientific publications, imperative for me to include math in my x- and y-axis labels.
e.g. there seems to be no "q" subscript in Unicode so I must resort to LaTeX here. and it gives me two different fonts for my x- and y-axis labels. any way to mix LaTeX font for the variables with regular (nice-looking) font for the non-math mode? see how the x- and y-axis labels are in a different font?
sure, a solution for consistent font is to use LaTeX mode for everything, but this font for LaTeX is incredibly ugly. I'm thinking about matplotlib that allows LaTeX and text seamlessly.
ax = Axis(fig[2, 1], xlabel=L"$c_{eq}$ [ng/cm$^3$]", ylabel="D [nm²/s]")

I use "CMU Serif", it's not exactly the same but it looks good enough.
https://lazarusa.github.io/BeautifulMakie/ScattersLines/besselFunctions/
I also thought that it might be worthwhile to add some really simple markup syntax to our default layout algorithm which could handle super and subscripts. It's kind of unnecessary to rely on unicode for that, especially because we know coverage is not great. Maybe something html-looking like x<sub>q</sub> or so?
thanks for the tip! this is a decent patch, but honestly not a fan of the CMU Serif font / being restricted to this for all of my plots.
allowing for html to make super and subscripts would be a great start! I'm finding myself changing variable names in my papers (to less ideal/clear ones) to accommodate Unicode/CairoMakie. :eyes:
@jkrumbiegel is there any way to make a subscript \infty? :cry:
you mean this, or?
using GLMakie, LaTeXStrings
fig, ax, obj = lines(0..2π, sin;
label = L"sin_{\infty}(x)",
figure = (;fontsize = 38))
axislegend(ax)
fig
@lazarus, I'm trying to avoid the ugly LaTeX font so was wondering if this is possible with the unicode character.
maybe I'm better off asking MathTeXEngine.jl to implement a sans serif LaTeX font?
This could be done with RichText now, if it wasn't for https://github.com/MakieOrg/Makie.jl/issues/2838
fig, ax, obj = lines(0 .. 2π, sin;
figure=(; fontsize=38),
axis=(; title=rich("sin", subscript("∞"), "(x)")))
fig
yeah, the rich text = a huge improvement. been using it. thanks!
that said, something like supporting fira math font or allowing to change the LaTeX style would still be a game changer for me. eg. snapshot from my recent paper (barely acceptable).
@Kolaru pointed out that one just needs 2 small little tweaks per font, which are probably these numbers here: https://github.com/Kolaru/MathTeXEngine.jl/blob/master/src/engine/fonts.jl#L91-L106 Would be nice to have a little test plot, to see & tweak those numbers and make it easy to add a new font this way
I also suggested a little GLMakie app to tweak these per font.
And I had super-subscript for rich before, but removed it due linebreak ambiguities. But I might be able to bring it back