本文介绍了Matplotlib图未显示在Mac OSX中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Mac OSX 10.5.8.我使用macports安装了matplotlib.我从matplotlib画廊获得了一些像这样的示例,而无需进行修改:

I am running Mac OSX 10.5.8. I installed matplotlib using macports. I get some examples from the matplotlib gallery like this one, without modification:

http://matplotlib.sourceforge.net/examples/api/unicode_minus.html

我运行它,没有错误,但是图片没有显示.在Linux Ubuntu中,我明白了.

I run it, get no error, but the picture does not show up. In Linux Ubuntu I get it.

您知道这里可能出什么问题吗?

Do you know what could be wrong here?

推荐答案

我也可以在此进行验证.要解决,这是我所做的

I can verify this on my end as well. To fix, here's what I did

sudo port install py25-matplotlib +cairo+gtk2
sudo port install py26-matplotlib +cairo+gtk2

此外,我们需要将默认后端更改为基于GUI的后端.

Also, we need to change the default backend to a GUI based one.

编辑文件~/.matplotlib/matplotlibrc,然后添加:

backend: GTKCairo


此外,您可以尝试以下操作,这可能使您不需要GTK或Cairo后端.编辑~/.matplotlib/matplotlibrc并添加:


Also, you can try the following, which may allow you to not need the GTK or Cairo backends.Edit ~/.matplotlib/matplotlibrc and add:

backend: MacOSX

安装了具有这些变体的端口后,它也可以正常工作,但是不需要X11.

With the port with those variants installed, this works as well, but it doesn't require X11.

顺便说一句,我看到的错误如下:

By the way, the error that I saw was the following:

/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/__init__.py:41: UserWarning:
Your currently selected backend, 'Agg' does not support show().
Please select a GUI backend in your matplotlibrc file ('/Users/wlynch/.matplotlib/matplotlibrc') or with matplotlib.use()
(backend, matplotlib.matplotlib_fname()))

这篇关于Matplotlib图未显示在Mac OSX中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:43