3

I am using Julia (with the IJulia plugin for Jupyter notebooks). How do I get unicode characters to display correctly in my plot?

Here is my code:

using PyPlot
ϕ = linspace(-0.25, 1.25, 100);
f = (ϕ.^2).*(1.0-ϕ).^2;
figure(figsize=(8,5))
plot(ϕ, f, color="purple", linewidth=1.8, linestyle="-")
xlabel("ϕ")
ylabel("f(ϕ)")

However, the plot does not show the unicode character, ϕ, properly:

plot

spencerlyon2
  • 9,476
  • 4
  • 30
  • 39
nathanielng
  • 1,645
  • 1
  • 19
  • 30

1 Answers1

7

PyPlot support LaTeX commands, in this case:

xlabel(L"$\phi$")
ylabel(L"$f(\phi)$")
Dawny33
  • 10,543
  • 21
  • 82
  • 134
elsuizo
  • 144
  • 1
  • 3