如何从图形对象显示matplotlib图 [英] How to show matplotlib plot from a figure object

查看:74
本文介绍了如何从图形对象显示matplotlib图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码包含以下几行:

My code contains the following lines:

from matplotlib.figure import Figure

figure = Figure(figsize=(10, 5), dpi=dpi)

如何获取matplotlib来显示此图?我还展示了它嵌入在 tkinter 中,效果很好.但是,我也可以在标准的matplotlib窗口中显示它.但是我无法一辈子让它正常工作.

How can I get matplotlib to show this figure? I also show it embedded in tkinter, which workes fine. However I would also be able to show it in the standard matplotlib window. But I can't for the life of me get it to work.

推荐答案

我通常使用matplotlib的pyplot立即生成(或在jupyter笔记本中生成图像).这将如下所示:

I usually use matplotlib's pyplot for immediate generation (or produce images in jupyter notebooks). This would look like the following:

import matplotlib.pyplot as plt

figure = plt.figure(figsize=(10, 5), dpi=dpi)
plt.show()

这显示了所需的(空白)数字.

This shows the (blank) figure as desired.

这篇关于如何从图形对象显示matplotlib图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆