2

我最近正在努力使 auto07p 与 matplotlib 2.0 一起工作。

源代码可以在这里找到: https ://sourceforge.net/projects/auto-07p/files/auto07p/0.9/

使用 matplotlib 2.0(或任何大于 1.5 的版本)时,IndexError: invalid index to scalar variable。出现:

/home/ngb/auto/07p/python/Points.py:1086: VisibleDeprecationWarning: `rank` is deprecated; use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.
  r = rank(array_temp)
Created plot
<graphics.windowPlotter.WindowPlotter2D object at 0x7f9e42007710>
AUTO> Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1562, in __call__
    return self.func(*args)
  File "/usr/lib/python3.5/tkinter/__init__.py", line 608, in callit
    func(*args)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 370, in idle_draw
    self.draw()
  File "/home/ngb/auto/07p/python/graphics/grapher_mpl.py", line 92, in draw
    self.redraw()
  File "/home/ngb/auto/07p/python/graphics/grapher_mpl.py", line 65, in redraw
    FigureCanvasTkAgg.draw(self)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 351, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 464, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1143, in draw
    renderer, self, dsu, self.suppressComposite)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2409, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 1136, in draw
    ticks_to_draw = self._update_ticks(renderer)
  File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 969, in _update_ticks
    tick_tups = [t for t in self.iter_ticks()]
  File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 969, in <listcomp>
    tick_tups = [t for t in self.iter_ticks()]
  File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 912, in iter_ticks
    majorLocs = self.major.locator()
  File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1794, in __call__
    return self.tick_values(vmin, vmax)
  File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1802, in tick_values
    locs = self._raw_ticks(vmin, vmax)
  File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1761, in _raw_ticks
    istep = np.nonzero(steps >= raw_step)[0][0]
IndexError: invalid index to scalar variable.

似乎只涉及两条线。它们来自文件 /auto/07p/python/graphics/grapher_mpl.py。

涉及的两种方法是:

 def redraw(self):
        # recalculate label positions
        self.grapher.plotlabels()

        FigureCanvasTkAgg.draw(self)

def draw(self):
    ax = self.grapher.ax
    d = {}
    if ax is self.grapher.ax3d:
        [d["minx"], d["maxx"]] = ax.get_xlim3d()
        [d["miny"], d["maxy"]] = ax.get_ylim3d()
        [d["minz"], d["maxz"]] = ax.get_zlim3d()
        d["azimuth"] = ax.azim
        d["elevation"] = ax.elev
        d["cur_lims"] = Axes.get_xlim(ax), Axes.get_ylim(ax)
    else:
        [d["minx"], d["maxx"]] = ax.get_xlim()
        [d["miny"], d["maxy"]] = ax.get_ylim()
    for k in list(d):
        # don't adjust any unchanged settings
        if k == "cur_lims":
            if map(list, d[k]) == map(list, self.grapher._cur_lims):
                del d[k]
        elif d[k] == self.grapher.cget(k):
            del d[k]
    if d != {}:
        if "cur_lims" in d:
            del d["cur_lims"]
        if d != {}:
            self.grapher._configNoDraw(**d)

        self.redraw()
        return
    FigureCanvasTkAgg.draw(self)

如果有人可以帮助我解决错误,我将不胜感激,而无需更改 matlibplot 代码,而只更改自动代码。我已经阅读了代码,但没有发现任何可疑之处。

我使用给定的方程式和自动文件遇到了这个错误。但是,如果您使用 matplotlib 2.0 和 auto07p 来绘制大多数图表,那么如果您放大图表,您很可能会收到此错误。

我使用的文件如下:

https://1drv.ms/f/s!ArJqyyCr1FQOhkITst8JdVK_mIFV

将它们放在自动文件夹中。运行自动。并输入:

汽车(“情侣2.汽车”)

谢谢。

4

0 回答 0