簡體   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