Is there an efficient way that the xticks and yticks numbers appear in LaTeX using Makie?

I open this question because I have not been able to set the Computer Modern font in Makie. The only workaround I found to write the numbers of the x and y axis in LaTeX is to extract the attribute from the plot that contains these numbers and manually changing them to LaTeX with the notation L"number" and then putting them back into the corresponding attributes that contains these labels.

However, I think that there should be a way where you just change the font of the whole plot but I did not manage to find it in the documentation or other related questions.

using GLMakie

function example_plot(;font, fontsize)
    f = Figure(font = font, fontsize = fontsize)
    lines(f[1, 1], cumsum(randn(50)))
    f
end

example_plot(font = "Computer Modern", fontsize = 30)

Thank you for your response! But that does not look like LaTeX right?

In this other example, using the Plots package, that font produces LaTeX figures. When I run the code using “Computer Modern” with Makie I get a message saying that font does not exist and if defaults to “Dejavu Sans”

Yes. Maybe something is wrong with “Computer Modern” font in my laptop, so I install a new “Computer Modern” font and it looks right now.

And, It seems you got the message because Makie did not find the font in your computer. It`s a general issue in Frequently Asked Questions (juliaplots.org).

If Makie can’t find your font, you can do two things:

  1. Check that the name matches and that the font is in one of the directories in:
  • using FreeTypeAbstraction; FreeTypeAbstraction.valid_fontpaths
  1. You can add a custom font path via the environment variable:
  • ENV["FREETYPE_ABSTRACTION_FONT_PATH"] = "/path/to/your/fonts"
  1. Specify the path to the font; instead of font = "Noto" , you could write joindir(homedir(), "Noto.ttf") or something.

Good luck!

Okay now it works! Thank you very much!