繁体   English   中英

在 matplotlib 中更改 fonts 无法正常工作

[英]changing fonts in matplotlib not working properly

我在更改 mathplotlib 中的 fonts 时遇到问题。 我尝试构建一个 3d 绘图并希望轴为 arial 字体。 这是我的代码:

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 没有错误...

谢谢帮助

据我所知,这个错误是因为没有安装字体而引发的。

在 windows 上,检查“charmap”。 所有这些 fonts 都可以使用。

Helvetica 默认情况下似乎不包括在内。 你必须找到它并安装它。 使用 Windows 10 和 python 3.7 尝试并测试了我的结果

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM