Python 设置图表的标签

Python 设置图表的标签,python,matplotlib,Python,Matplotlib,我从matplotlib站点复制了这个示例,现在我想更改标签的字体、颜色和大小,但不更改数字大小。有可能看到中间和两端的数字吗? from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.

我从matplotlib站点复制了这个示例,现在我想更改标签的字体、颜色和大小,但不更改数字大小。有可能看到中间和两端的数字吗?

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25]
Z = np.sqrt(np.abs(np.cos(X) + np.cos(Y)))

surf = ax.plot_surface(X + 1e5, Y + 1e5, Z, cmap='autumn', cstride=2, rstride=2)
ax.set_xlabel("X-Label")
ax.set_ylabel("Y-Label")
ax.set_zlabel("Z-Label")
ax.set_zlim(0, 2)

plt.show()

谢谢

创建标签时,您可以通过设置更改字体大小、颜色和类型,如下所示:

ax.set_xlabel("X-Label", size  = 40, color = 'r', family =  'fantasy')

您可以使用控制显示哪些记号

一般来说,使用定位器比手动设置刻度位置更好。定位器是什么??我没用过。我怎么能只考虑中间和顶部的价值?因为在轴上没有太多的麻木
ax.get_yaxis().get_major_locator().set_params(nbins=3)
将获得三个刻度。(编辑、拼写)