【发布时间】:2014-03-08 16:34:06
【问题描述】:
当我在我的 3D.plot 上使用 axes.cla() 删除所有线条、修改轴'然后再次在该图上调用 draw() 时,轴标签和线条变得更粗。并且仅在轴上用ticker修改。我的猜测是我必须以某种方式删除旧的轴标签,我该怎么做?
这是我正在谈论的内容的最小示例代码。我将重绘链接到画布上的鼠标单击。代码是 Python 3 的。(我已经尝试过使用 clf() 的解决方法并重绘整个图形,但在 3D 模式下它不起作用。)
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.ticker as ticker
def onclick(event):
event.inaxes.cla()
event.inaxes.w_xaxis.set_major_locator(ticker.LinearLocator())
event.inaxes.w_xaxis.set_major_locator(ticker.LinearLocator())
event.canvas.draw()
fig = plt.figure()
axes = fig.add_subplot(111, projection='3d')
fig.canvas.mpl_connect('button_press_event', onclick)
plt.show()
【问题讨论】:
标签: python matplotlib ticker