消失的轴,LogLog绘图Python

时间:2014-03-06 21:07:43

标签: python matplotlib

我正在运行一个循环来绘制一堆不同的线,但最有意义的是将它们绘制在loglog图上(处理大约9个数量级)。他们用loglog绘图绘制它们应该如何绘制,但是只有当我尝试记录它们时,轴/轴标签才会消失。

#THIS IS FOR A NORMAL PLOT
import matplotlib.pyplot as plt

plt.figure()
for ii in list1:
    plt.plot(xarray[:], yarray[ii,:])
plt.show()

我尝试添加以下内容:

plt.xscale('log')

plt.yscale('log')

或者我试过

plt.loglog(xarray[:], yarray[ii,:])
plt.semilogy(xarray[:], yarray[ii,:])

任何帮助都会很棒,我对绘图的经验不多,但是我认为制作轴应该非常简单。感谢。

My plot without the axes

编辑:我也从traceback获得以下错误调用。我只是做了一个干净的重新安装matplotlib并仍然有相同的问题(它绘制但没有轴)

>Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1034, in draw
    func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.py", line 2086, in draw
    a.draw(renderer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axis.py", line 1093, in draw
    renderer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axis.py", line 1042, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/text.py", line 754, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/text.py", line 329, in _get_layout
    ismath=ismath)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 151, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 3009, in parse
    self.__class__._parser = Parser()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 2193, in __init__
    - ((lbrace + float_literal + rbrace)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'

1 个答案:

答案 0 :(得分:0)

原来这个问题是由于出现同样问题造成的: In this Problem

我完全卸载了python,重新安装了python(适用于Mac OSX 10.3及更高版本的32位版本),matplotlib,scipy和numpy。现在轴正确绘制。