matplotlib mac OSX 10.8切断了刻度线和轴标签

时间:2013-03-20 13:16:40

标签: macos matplotlib

我的matplotlib安装似乎是切断刻度线标签和截断轴标签。例如,绘图的代码示例具有从0到20的y轴值。垂直轴似乎只打印最左边的数字,或者最左边的数字带有符号,0,5,1,1,2,它应该在哪里打印是0.0,5.0,10.0,15.0,20.0。垂直轴标签打印'Amplitu',它应该是'Amplitude,arb'更改字体大小或使用窗口拉伸缩放图不会改变行为。 python代码:

from numpy import arange, sin, pi
from numpy import ma
from matplotlib.pyplot import  plot, show, title, xlabel, ylabel

t = arange(0.0, 2.0, 0.01)
s = 20*sin(2*pi*t)

plot(t,s,'g')
title("Sinewave Plot Example", fontsize=10)
xlabel("Elapsed Time, arb", fontsize=10)
ylabel("Amplitude, arb", fontsize=10)
show()

这似乎是安装/配置问题而不是编码问题。以上应该工作正常。

我在Mac OSX 10.8 Mountain Lion上安装了matplotlib,命令如下

sudo pip install numpy
sudo pip install scipy 
sudo pip install matplotlib
Downloading/unpacking matplotlib
  Downloading matplotlib-1.2.0.tar.gz (36.9MB): 36.9MB downloaded
  Running setup.py egg_info for package matplotlib
    basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local']
    ============================================================================
    BUILDING MATPLOTLIB
                matplotlib: 1.2.0
                    python: 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
                            [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
                  platform: darwin

    REQUIRED DEPENDENCIES
                     numpy: 1.7.0
                 freetype2: found, but unknown version (no pkg-config)

    OPTIONAL BACKEND DEPENDENCIES
                    libpng: found, but unknown version (no pkg-config)
                   Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
                      Gtk+: no
                            * Building for Gtk+ requires pygtk; you must be able
                            * to "import gtk" in your build/install environment
           Mac OS X native: yes
                        Qt: no
                       Qt4: no
                    PySide: no
                     Cairo: no

    OPTIONAL DATE/TIMEZONE DEPENDENCIES
                  dateutil: matplotlib will provide
                      pytz: matplotlib will provide
                       six: matplotlib will provide

    OPTIONAL USETEX DEPENDENCIES
                    dvipng: no
               ghostscript: /bin/sh: gs: command not found
                     latex: no

    [Edit setup.cfg to suppress the above messages]

当我尝试从Mac窗口.png文件保存绘图时,python解释器生成以下错误(3.3 w / ipython)

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/matplotlib/backends/backend_macosx.py", line 475, in save_figure
    self.canvas.get_default_filename())
ValueError: character U+55002f is not in range [U+0000; U+10ffff]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 0: invalid continuation byte

提前感谢您提供的任何见解!

1 个答案:

答案 0 :(得分:2)

这是known bug。解决方案可能是使用Python 2.7.3。