报错了 Traceback (most recent call last): File "D:\CAD\2 pycharm\py_lxl\test01_5.9\demo\test09.5.py", line 32, in <m

动态 未结 0 121
小小草
小小草 LV1 2023年9月23日 23:40 发表
这个错误是因为 `set_ticks_position` 方法中的参数只支持 `'top'`、`'bottom'`、`'both'`、`'default'` 和 `'none'` 这几个值。你可以将代码中的 `'left'` 改为 `'bottom'`,即可去掉左边框的刻度线。 修改后的代码如下: ```python import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(projection='3d') # 将相位向后移动了6*pi [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 20 * np.pi + 4*np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) # 添加边缘扰动 change = np.sin(15*t)/150 # 将t的参数减少,使花瓣的角度变大 u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) h = u * (x * np.cos(p) - y * np.sin(p)) c= plt.get_cmap('Reds') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) # 去掉上边框和右边框 ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) # 去掉下边框和左边框的刻度线 ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('bottom') plt.show() ```
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复