如何让函数在python中返回图形(使用matplotlib)? [英] How to have a function return a figure in python (using matplotlib)?
本文介绍了如何让函数在python中返回图形(使用matplotlib)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一些数据,并且我想通过将其传递到自定义绘图函数(myplot())来创建此数据的绘图.我在myplot()中使用了matplotlib的模块.
Assume that I have some data, and I want to create a plot of this data by passing it to a custom plotting function (myplot()). I am using the matplotlib's modules in myplot().
当我调用此函数时,我希望myplot()将句柄返回到图形,而不希望绘图显示绘图.这是iPython的示例代码和输出.
I would like myplot() to return the handle to a figure, and not plot display the plot when I call this function. Here is a sample code and output from iPython.
对此我有两个问题:
- 即使我分配了输出,为什么仍能看到一个图 myplot()转换为f?
- 将myplot()的输出分配给变量时,我需要什么来抑制该图?
- Why do I still see a plot, even though I am assigning the output of myplot() to f?
- What do I need to supress this plot when I am assigning the output of myplot() to a variable?
推荐答案
使用
ipython notebook
而不是
ipython notebook --pylab=inline
这篇关于如何让函数在python中返回图形(使用matplotlib)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文