matplotlib 3d:移动刻度的标签

时间:2021-01-23 22:58:07

标签: python matplotlib

有没有办法像这样在 Matplot3dlib 中移动刻度标签? enter image description here

from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = x.copy().T # transpose
z = np.cos(x ** 2 + y ** 2)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
ax.set_title('Surface plot')
plt.show()

some ways using pad parameters
但是,我想像上面链接中的图一样更精确地移动。
任何帮助表示赞赏。

-- 添加 --

当我像下面的代码一样更改 PAD 参数时,刻度的标签更靠近轴。但是,我想将它稍微移动到 -x 方向。 tick's label position changing

from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = x.copy().T # transpose
z = np.cos(x ** 2 + y ** 2)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
ax.set_title('Surface plot')
ax.tick_params(axis='x', which='major', pad=-5)
plt.show()

0 个答案:

没有答案
相关问题