使用 matplotlib 绘制 3D 绘图,draw() 需要一个附加参数
各位。昨天我正在探索 matplotlib 的 3D 绘图功能(很惊喜,它看起来不错)。需要明确的是
from mpl_toolkits.mplot3d import Axes3D
,当我尝试使用draw()连续重绘绘图时,我收到错误,draw()(对于3d图)除了self之外还需要一个额外的参数。该参数称为渲染器,并且不是可选的。查看 3d 轴的代码,我找不到应该作为渲染器放置的内容的规范。
您知道我应该如何解决这个问题吗?需要明确的是,我可以将 draw() 与普通绘图一起使用(打开 ion() 等),所以我的问题仅与 Axes3D 有关。
基本上,我想模仿我已经在 matlab 中编写的一些代码,它绘制 3d 绘图,然后更新它(使用drawow())。
编辑:我意识到渲染器参数可能是特定于计算机的。我坐在 Windows 上,安装了 Enthought Python。如果您需要更多信息,请告诉我。
Dear all. I was exploring matplotlib's 3d plot capabilities yesterday (and was pleasantly surprised, it looks good). Just to be clear, with
from mpl_toolkits.mplot3d import Axes3D
However, when I try to continuously redraw the plot with draw(), I get the error that draw() (for 3d plots) takes an additional argument aside from self. This argument is called renderer, and is not optional. Looking through the code for 3d axes, I couldn't find a specification of what I should put as renderer.
Do you have any idea how I should work around this problem? Just to be clear, I can use draw() with normal plots (turning ion() on etc.), so my issue is only with Axes3D.
Basically, I want to mimick some code I already wrote in matlab, which draws a 3d plot and then updates it (with drawnow()).
EDIT: I realized that the renderer argument might be computer specific. I am sitting on a Windows with the Enthought installation of Python. If you need more information, let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:我收回它。您可以从fig.canvas.renderer 获取它。不过,我将保留下面的示例。
似乎没有记录的获取渲染器的方法,但您可能可以在 _cachedRenderer 的轴结构中查看。请注意,您必须在设置之前绘制绘图。
请参阅此示例的最后一行:
EDIT: I take it back. You can get it from
fig.canvas.renderer
. I'll leave the example below, though.There does not appear to be a documented way to get the renderer, but you can probably just peek within the axes structure at the _cachedRenderer. Note that you have to cause a plot to draw before this is set.
See the last line of this example: