I am trying to make a plot with the math symbol:
in the ylabel, which appears in latex as "\mathcal{I}", but this specific symbol cannot be made in Plots.jl. When entering "\mathcal{I}", you instead get:
Here is a MWE:
using Plots
using LaTeXStrings
plot([1],[1],ylabel=L"\mathcal{I}")
Which produces:
The wrong symbol on the y-axis. I have gathered that this is because Plots.jl is using a different font package. Is there any way to change which font package it uses?
I have many many plots, entire libraries really, written using Julia Plots. The convention in my field is to use "\mathcal{I}" and so it would be a great pain for me to change everything in my paper to use "\mathcal{J}" just because this one library cannot print the right symbol.
Any help would be appreciated.
Edit: Thanks to advice from @BallpointBen, I have tried the following code:
default(;fontfamily="Bookman"); plot([1],[1],ylabel=L"\mathcal{I}")
Unfortunately, for me this produces the error:
I should point out that it works fine if one renders empty latex or not latex at all. For example, the following code works:
default(;fontfamily="Bookman"); plot([1],[1],xlabel="",ylabel=L"")
It is only when at least one character in the latex string is asked for (e.g. L"1") that there is a problem. I further realised that the following actually works to get the right symbol:
default(;fontfamily="Times Roman");plot([1],[1],ylabel="")
Which produces:
Quite a few font families work by just inserting this literal character, but alas, if one tries to include latex as well, one gets the same error. That is, I try
default(;fontfamily="Times Roman"); plot([1],[1],ylabel=string("",L"1"))
And obtain:
One final idea that does not work is trying to make the character normal text within the latex string as follows:
default(;fontfamily="Times Roman"); plot([1],[1],ylabel=L"\textrm{}")
Which produces the same output as the first picture that I sent showing the error.
I am looking into solving this error.




When using the GR backend, you can find the list of available fonts here. You can set the default font of Plots.jl using
default. You have a lot of fonts to choose from, but one that (sort of) works is Bookman.Or you can set the font directly:
Result:
Unfortunately this results the LateX being pixelated — not sure why.
Also unfortunate is that the Unicode character
U+2110Script Capital I, which might've been a suitable substitute, is rendered as something like ℐ in basically every font.Of course, you do not need to use the GR backend. The PGFPlotsX backend uses LaTeX natively (how? not sure, I think it writes tikx and renders it). You will need to
]add PGFPlotsX.This produces a (high-res) PDF, which I've converted to an image below: