I’m trying to achieve an homogeneous looking plot where every element of the plot has Computer Modern font using the PyPlot package.
Following some of the answers to existing questions in the forum, this is as close as I’ve gotten:
using PyPlot
using LaTeXStrings
PyPlot.matplotlib[:rc]("text", usetex=false)
PyPlot.matplotlib[:rc]("mathtext",fontset="cm")
PyPlot.matplotlib[:rc]("font",family="serif",size=12)
x = range(0; stop=2*pi, length=1000); y = sin.(3 * x + 4 * cos.(2 * x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
title(L"\sin(3x + 4\cos(2x))")
xlabel(L"x")
ylabel(L"y");
With the following output
But the ticks’s numbers aren’t in Computer Modern font. Additionally, setting
By inline plots I refer to the plots generated in a Jupyter Notebook’s cell. Setting that line to true in a Jupyter Notebook session just results in the following message
Figure(PyObject <Figure size 640x480 with 1 Axes>)
Font 'default' does not have a glyph for '\u2212' [U+2212], substituting with a dummy symbol.
According to the discussion in the GitHub issue, after doing that you’d need to tell matplotlib to get the minus sign from some other font file. That’s what I wouldn’t know how to do.