Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poor handling of LaTeX in x- and y-axis labels #2197

Closed
SimonEnsemble opened this issue Aug 4, 2022 · 10 comments
Closed

poor handling of LaTeX in x- and y-axis labels #2197

SimonEnsemble opened this issue Aug 4, 2022 · 10 comments
Labels
enhancement Feature requests and enhancements Makie Backend independent issues (Makie core) planning For discussion and planning development text

Comments

@SimonEnsemble
Copy link

❤️ 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]")

image

@lazarusA
Copy link
Contributor

lazarusA commented Aug 4, 2022

I use "CMU Serif", it's not exactly the same but it looks good enough.
https://lazarusa.github.io/BeautifulMakie/ScattersLines/besselFunctions/
besselFunctions

@jkrumbiegel
Copy link
Member

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?

@SimonEnsemble
Copy link
Author

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. 👀

@SimonEnsemble
Copy link
Author

@jkrumbiegel is there any way to make a subscript \infty? 😢

@lazarusA
Copy link
Contributor

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

Screenshot 2022-09-25 at 18 31 59

@SimonEnsemble
Copy link
Author

@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?

@SimonDanisch
Copy link
Member

This could be done with RichText now, if it wasn't for #2838

fig, ax, obj = lines(0 .. 2π, sin;
figure=(; fontsize=38),
axis=(; title=rich("sin", subscript(""), "(x)")))
fig

image

@SimonEnsemble
Copy link
Author

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).

Screenshot 2023-04-27 at 10 53 52 AM

@SimonDanisch
Copy link
Member

@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

@jkrumbiegel
Copy link
Member

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

@t-bltg t-bltg added the text label Oct 25, 2023
@ffreyer ffreyer added enhancement Feature requests and enhancements planning For discussion and planning development Makie Backend independent issues (Makie core) labels Aug 23, 2024
@MakieOrg MakieOrg locked and limited conversation to collaborators Aug 23, 2024
@ffreyer ffreyer converted this issue into discussion #4220 Aug 23, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement Feature requests and enhancements Makie Backend independent issues (Makie core) planning For discussion and planning development text
Projects
Status: Done
Development

No branches or pull requests

6 participants