python - Matplotlib 1.0.1 至 1.4.2

标签 python python-2.7 matplotlib

我是 Python 的新手,我正在尝试调试同时使用 TKinter 和 MatPlotLib 的代码。最初,我使用 Python 2.6.2 和 MatPlotLib 1.0.1。我最近使用 MatPlotLib 1.4.2 更新到 Python 2.7……相当大的一个跳跃,一个颠簸的跳跃。

这是我的代码,它是图形界面的一部分,其中显示了一个根据用户给定的参数更新的图形:

## -- Algorithm is over, graph the results:
self.graph = Figure()
self.curve = self.graph.add_subplot(111, animated = TRUE, aspect = self.aspectRatio)
self.curve.set_title(translate['my figure'])
self.curve.set_xlabel(translate['xlabel'])
self.curve.set_ylabel(translate['ylabel'])
self.canvas = FigureCanvasTkAgg(self.graph, master = self.leftFrame)
self.canvas.show()
self.canvas.get_tk_widget().pack(pady=15)
self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.leftFrame )    
self.toolbar.update()                                   
self.canvas._tkcanvas.pack()
self.inputBox[1][1].focus_set()

更新到 Python 2.7 后,我在图形界面中基本上看不到任何东西,没有绘制图形。令我惊讶的是,绝对没有错误信息。

因此我认为从 MatPlotLib 1.0.1 到 1.4.2 实际绘制或显示图表的方式可能有一些修改。有什么明显的我在这里失踪了吗?任何人都可以知道 MatPlotLib 中可能发生的变化会导致此问题吗?

我希望我能更具体一些,但是没有错误消息使得调试变得非常困难...


我一直在调查这个问题,发现问题出现在从 MatPlotLib 1.0.1MatPlotLib 1.1.1 的过程中,这缩小了我对发行说明的扫描范围 ( MatPlotLib, what is new in 1.1 ) 以了解发生了什么。

最佳答案

问题是您将“动画”设置为 true 而您实际上并没有制作动画(至少不是您所展示的动画)。改变

self.curve = self.graph.add_subplot(111, animated = TRUE, aspect = self.aspectRatio)

self.curve = self.graph.add_subplot(111, aspect = self.aspectRatio)

如果你想做一个动画here是一个例子。

关于python - Matplotlib 1.0.1 至 1.4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27301914/

相关文章:

python - 使用 python 正则表达式避免引号内的模式

python /Matplotlib : adding regression line to a plot given its intercept and slope

python - Matplotlib 轴标签部分的斜体 - 应用于默认字体但不指定字体

python - 类型错误 : '>=' not supported between instances of 'list' and 'int'

python - 是否必须安装 pygame 才能运行 pygame 游戏?

python - 为什么我的删除按钮没有删除我的数据库对象? Django

python - 无法同步数据库

python - pygtk+glade+本地化

在主进程中从标准输入进行阻塞读取时,Python 子进程阻塞

python - 使用 Numpy 和 Matplotlib 绘制具有多个数据值的图表