【问题标题】:Updating Matplotlib 3D with new data and ticker values使用新数据和代码值更新 Matplotlib 3D
【发布时间】: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


    【解决方案1】:

    我通过不使用cla() 得到了解决方法。我只删除了axes.linesaxes.collections 中的绘图数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 2011-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 1970-01-01
      相关资源
      最近更新 更多