![]() | 1 | initial version |
not sure this is answering your question but now it's ok for me no more error, you just need to install like it is said here:
https://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
now it's ok for me in9.4 W10 WSL2 UBUNTU 20.04 , you just need to install supplementary package like it is said here
with the command :
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
but there is a default \text{blabla} still does not work ;-(
![]() | 2 | No.2 Revision |
not sure this is answering your question but now it's ok for me no more error, you just need to install like it is said here:
https://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
now it's ok for me in9.4 W10 WSL2 UBUNTU 20.04 , you just need to install supplementary package like it is said here
with the command :
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
but there is a default \text{blabla} still does not work ;-(
this code is now also working for me now(it was not before the new package):
fig, ax = plt.subplots()
# interface tracking profiles
N = 500
delta = 0.6
X = np.linspace(-1, 1, N)
ax.plot(X, (1 - np.tanh(4 * X / delta)) / 2, # phase field tanh profiles
X, (1.4 + np.tanh(4 * X / delta)) / 4, "C2", # composition profile
X, X < 0, "k--") # sharp interface
# legend
ax.legend(("phase field", "level set", "sharp interface"),
shadow=True, loc=(0.01, 0.48), handlelength=1.5, fontsize=16)
# the arrow
ax.annotate("", xy=(-delta / 2., 0.1), xytext=(delta / 2., 0.1),
arrowprops=dict(arrowstyle="<->", connectionstyle="arc3"))
ax.text(0, 0.1, r"$\delta$",
color="black", fontsize=24,
horizontalalignment="center", verticalalignment="center",
bbox=dict(boxstyle="round", fc="white", ec="black", pad=0.2))
# Use tex in labels
ax.set_xticks([-1, 0, 1])
ax.set_xticklabels(["$-1$", r"$\pm 0$", "$+1$"], color="k", size=20)
# Left Y-axis labels, combine math mode and text mode
ax.set_ylabel(r"\bf{phase field} $\phi$", color="C0", fontsize=20)
ax.set_yticks([0, 0.5, 1])
ax.set_yticklabels([r"\bf{0}", r"\bf{.5}", r"\bf{1}"], color="k", size=20)
# Right Y-axis labels
ax.text(1.02, 0.5, r"\bf{level set} $\phi$",
color="C2", fontsize=20, rotation=90,
horizontalalignment="left", verticalalignment="center",
clip_on=False, transform=ax.transAxes)
# Use multiline environment inside a `text`.
# level set equations
eq1 = (r"\begin{eqnarray*}"
r"|\nabla\phi| &=& 1,\\"
r"\frac{\partial \phi}{\partial t} + U|\nabla \phi| &=& 0 "
r"\end{eqnarray*}")
ax.text(1, 0.9, eq1, color="C2", fontsize=18,
horizontalalignment="right", verticalalignment="top")
# phase field equations
eq2 = (r"\begin{eqnarray*}"
r"\mathcal{F} &=& \int f\left( \phi, c \right) dV, \\ "
r"\frac{ \partial \phi } { \partial t } &=& -M_{ \phi } "
r"\frac{ \delta \mathcal{F} } { \delta \phi }"
r"\end{eqnarray*}")
ax.text(0.18, 0.18, eq2, color="C0", fontsize=16)
ax.text(-1, .30, r"gamma: $\gamma$", color="r", fontsize=20)
ax.text(-1, .18, r"Omega: $\Omega$", color="b", fontsize=20)
plt.show()
![]() | 3 | No.3 Revision |
not sure this is answering your question but now it's ok for me no more error, you just need to install like it is said here:
https://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
now it's ok for me in9.4 W10 WSL2 UBUNTU 20.04 , you just need to install supplementary package like it is said here
with the command :
sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super
but there is a default \text{blabla} still does not work ;-(
this code is now also working for me now(it was not before the new package):
fig, ax = plt.subplots()
# interface tracking profiles
N = 500
delta = 0.6
X = np.linspace(-1, 1, N)
ax.plot(X, (1 - np.tanh(4 * X / delta)) / 2, # phase field tanh profiles
X, (1.4 + np.tanh(4 * X / delta)) / 4, "C2", # composition profile
X, X < 0, "k--") # sharp interface
# legend
ax.legend(("phase field", "level set", "sharp interface"),
shadow=True, loc=(0.01, 0.48), handlelength=1.5, fontsize=16)
# the arrow
ax.annotate("", xy=(-delta / 2., 0.1), xytext=(delta / 2., 0.1),
arrowprops=dict(arrowstyle="<->", connectionstyle="arc3"))
ax.text(0, 0.1, r"$\delta$",
color="black", fontsize=24,
horizontalalignment="center", verticalalignment="center",
bbox=dict(boxstyle="round", fc="white", ec="black", pad=0.2))
# Use tex in labels
ax.set_xticks([-1, 0, 1])
ax.set_xticklabels(["$-1$", r"$\pm 0$", "$+1$"], color="k", size=20)
# Left Y-axis labels, combine math mode and text mode
ax.set_ylabel(r"\bf{phase field} $\phi$", color="C0", fontsize=20)
ax.set_yticks([0, 0.5, 1])
ax.set_yticklabels([r"\bf{0}", r"\bf{.5}", r"\bf{1}"], color="k", size=20)
# Right Y-axis labels
ax.text(1.02, 0.5, r"\bf{level set} $\phi$",
color="C2", fontsize=20, rotation=90,
horizontalalignment="left", verticalalignment="center",
clip_on=False, transform=ax.transAxes)
# Use multiline environment inside a `text`.
# level set equations
eq1 = (r"\begin{eqnarray*}"
r"|\nabla\phi| &=& 1,\\"
r"\frac{\partial \phi}{\partial t} + U|\nabla \phi| &=& 0 "
r"\end{eqnarray*}")
ax.text(1, 0.9, eq1, color="C2", fontsize=18,
horizontalalignment="right", verticalalignment="top")
# phase field equations
eq2 = (r"\begin{eqnarray*}"
r"\mathcal{F} &=& \int f\left( \phi, c \right) dV, \\ "
r"\frac{ \partial \phi } { \partial t } &=& -M_{ \phi } "
r"\frac{ \delta \mathcal{F} } { \delta \phi }"
r"\end{eqnarray*}")
ax.text(0.18, 0.18, eq2, color="C0", fontsize=16)
ax.text(-1, .30, r"gamma: $\gamma$", color="r", fontsize=20)
ax.text(-1, .18, r"Omega: $\Omega$", color="b", fontsize=20)
plt.show()
another exemple:
plt3=plot(x^2, legend_label=r'\TeX\ is Number $\displaystyle\sum_{n=1}^7'+
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='red')
show(plt3)