简体   繁体   English

Windows上的交互式matplotlib / ipython图形

[英]Interactive matplotlib/ipython figures on Windows

I'm having trouble getting matplotlib up and running on a recent Win7/Cygwin installation. 我在最近安装的Win7 / Cygwin安装和运行matplotlib时遇到问题。

I've use the Cygwin package manager to install python 2.7.8, but the mirrors I have tried don't seem to include packages for ipython or matplotlib. 我已经使用Cygwin软件包管理器安装了python 2.7.8,但是我尝试使用的镜像似乎并未包含ipython或matplotlib的软件包。 I've used Cygwin to install the prerequisite packages 我已经使用Cygwin安装必备软件包

pkg-config ghostscript libfreetype-devel libpng-devel python-gtk2.0 libgtk2.0-devel gcc-g++ git pkg-config ghostscript libfreetype-devel libpng-devel python-gtk2.0 libgtk2.0-devel gcc-g ++ git

(a list I found here ) and installed both matplotlib and ipython from their git repositories: (我在此处找到的列表)并从其git存储库安装了matplotlib和ipython:

git clone git://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install

cd ..

git clone https://github.com/ipython/ipython.git
cd ipython
python setup.py install

I can successfully plot from a standard python prompt by manually calling show() , or from an ipython session (started without --pylab ) also by manually calling show() . 我可以通过手动调用show()从标准python提示符下成功绘图,或者也可以通过手动调用show()从ipython会话(不使用--pylab开始)成功绘图。 In both cases show() blocks the terminal input until the plot window is closed, and closing the figure resets it so that subsequent plotting commands begin with a blank canvas. 在这两种情况下, show()阻塞终端输入,直到关闭绘图窗口为止,关闭图形会将其重置,以便后续绘图命令以空白画布开始。

If I run ipython --pylab , or run pylab.ion() from within ipython, then plotting commands bring up the canvas automatically as I'm used to on MacOS --- but the canvas never contains any visible axis, only a grey frame! 如果我在ipython --pylab运行ipython --pylab或运行pylab.ion() ,则绘图命令会像在MacOS上一样自动调出画布---但画布永远不会包含任何可见轴,只有灰色帧! In this case show() does nothing. 在这种情况下, show()不执行任何操作。 The figure does seem to be getting built somewhere: as I add lines and curves, I can call gca().get_children() and see that more figures are being added to the axis; 这个数字似乎取得了一些建:我添加的直线和曲线,我可以调用gca().get_children()看到更多的数据被添加到轴上; I can also use gcf().save_fig('foo.png') to put reasonable output to a file. 我还可以使用gcf().save_fig('foo.png')将合理的输出输出到文件中。 But for some reason the communication with the X window is broken. 但是由于某种原因,与X窗口的通信中断。

I believe that I'm using the TK backend; 我相信我正在使用TK后端; I'm not married to that choice, but it's not clear how I should install other backends. 我还没有选择那个,但是还不清楚我应该如何安装其他后端。

I would appreciate any guidance that ends with my plotting interactively. 我希望以交互式绘图结束的任何指导。

It seems to have been a transient bug due to having followed the head of the development tree. 由于遵循开发树的顶部,因此似乎是暂时的错误。 After updating this morning using 在今天早上更新后使用

git pull && python setup.py install

in both directories, I have proper interactive behavior. 在两个目录中,我都有适当的交互行为。

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

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