简体   繁体   English

在IPython笔记本中“重绘” matplotlib内联图

[英]“Replot” a matplotlib inline plot in a IPython notebook

if I work on a matplotlib inline plot in an ipython notebook like this: 如果我在ipython笔记本中的matplotlib 内联图上工作,如下所示:

figure = plt.figure()
ax = figure.gca(projection="3d")
graph = np.empty([len(thetaYield),3])
for g, tY in zip(graph, thetaYield):
    sample =  HWtoPS(xiYield, rhoYield, tY)
    g[...] = sample[:]
ax.plot(graph[:,0],graph[:,1], graph[:,2])
plt.show()

the plot is drawn inline in my notebook as it intended. 该图按预期在我的笔记本中内联绘制。

Now I want to add to add some data to this plot: 现在,我想添加一些数据以添加到该绘图中:

principalStress, vectors = eig(sigma)
ax.scatter(principalStress[0], principalStress[1], principalStress[2])
plt.show()

no error, but also no plot is drawn . 没有错误,也没有绘制曲线

I expected to get an "updated" version of my plot with the additional data. 希望获得带有其他数据的情节的“更新”版本。

How can this be done? 如何才能做到这一点?

A: This can be done at a cost of changed matplotlib Renderer 答:这可以通过更改matplotlib Renderer来实现

Currently, this cannot be done for the IPython "inline" graphs, however, if you opt to change a Renderer part of the matplotlib framework, to another one, the limitation of a singleton call of the .show() method does not hurt and you can ex post modify the object's content and it gets re-processed by the Renderer . 当前,对于IPython “内联”图无法做到这一点,但是,如果您选择将matplotlib框架的Renderer部分更改为另一个,则对.show()方法的单例调用的限制不会受到影响,并且您可以事后修改对象的内容,然后由Renderer对其进行重新处理。

Simply: 只是:

add a directive ( IPython magic ) %matplotlib qt 添加指令(IPython magic%matplotlib qt

&

use additional matplotlib calls as you expect 'em to modify/update the figure object 根据您的期望使用其他matplotlib调用来修改/更新figure对象

( I love using this both during prototyping phases & for interactive 3D-viewing of complex data visualisations (which I heavily miss in notebook's " inline "s) ) (我喜欢在原型开发阶段和用于复杂数据可视化的交互式3D查看(我在笔记本的“ 嵌入式 ”中很想念)中都使用此功能) matplotlib的3D视图 BTW : do you have about any methodology, which would allow to store a matplotlib 3D-view plot, as a complete, state-full container, that can be sent to some other user for her/his "load" and UI-interactive review? 顺便说一句 :您是否有任何方法可以将matplotlib 3D视图图存储为一个完整的,状态已满的容器,可以将其发送给其他用户以供其“加载”和UI交互查看? Would be great to hear about any such working :o) 听到任何这样的工作将是很棒的:o)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM