我在mathplotlib中更改字体时遇到问题。我试着建立一个3d-plot,并希望轴以数字字体显示。下面是我的代码:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Argumentwerte als 1D Arrays erzeugen
x_Leistung = np.linspace(1050,1350,100)
y_Vorschub = np.linspace(0.8,1.2,200)
# Argumentwerte als 2D Arrays erzeugen
x_Leistung, y_Vorschub = np.meshgrid(x_Leistung, y_Vorschub)
# Interessante Daten erzeugen
z_Nahtbreite_Kupfer = 497.142+114.478*((x_Leistung-1200)/150)+16.313*(0/15)-39.4*((y_Vorschub-1)/0.2)+(0/15)*(((y_Vorschub-1)/0.2)*13.432)+(0/15)*((0/15)*(-53.144))
# Plotten
plt.figure()
ax = plt.gca(projection='3d')
ax.plot_surface(x_Leistung, y_Vorschub, z_Nahtbreite_Kupfer, cmap=plt.get_cmap("gist_gray"))
#Achsen labeln
rcfont = {'fontname' : 'Arial'}
ax.set_xlabel('$power (W)$', size='medium',**rcfont)
ax.set_ylabel('$welding speed (m/min)$', size='medium',**rcfont)
ax.set_zlabel('$weld seam width copper (mm)$', size='medium',**rcfont)
plt.show()没有错误,但字体仍然是默认字体。有什么想法可以改变这一点吗?当我尝试helvetica时,出现找不到字体的错误,但Arial没有错误...
thx帮助
发布于 2019-11-22 19:44:18
据我所知,这个错误是因为字体没有安装而引发的。
在windows上,检查“charmap”。所有这些字体都可以使用。
看起来Helvetica在默认情况下是不包含的。你必须找到它并安装它。使用Windows 10和python 3.7对我的终端进行了测试
https://stackoverflow.com/questions/58993450
复制相似问题