0

以下の関数 (saveFigure) は、x が日付である独立したインスタンスを実行するときに正常に動作します。x は時間です。

しかし、1 つの Python インスタンスで、x を日付として、次に x を時間としてこの関数を呼び出すと、以下のエラーが発生します。

  plt.savefig(param.location + os.sep + param.fileName + str(dim) + '.png')
  File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 472, in savefig
    return fig.savefig(*args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\figure.py", line 1370, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 161, in print_figure
    FigureCanvasAgg.print_figure(self, *args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\backend_bases.py", line 2096, in print_figure
    **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_agg.py", line 492, in print_png
    FigureCanvasAgg.draw(self)
  File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_agg.py", line 440, in draw
    self.figure.draw(self.renderer)
  File "C:\Anaconda\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\figure.py", line 1006, in draw
    func(*args)
  File "C:\Anaconda\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\axes.py", line 2086, in draw
    a.draw(renderer)
  File "C:\Anaconda\lib\site-packages\matplotlib\artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Anaconda\lib\site-packages\matplotlib\axis.py", line 1050, in draw
    ticks_to_draw = self._update_ticks(renderer)
  File "C:\Anaconda\lib\site-packages\matplotlib\axis.py", line 937, in _update_ticks
    tick_tups = [t for t in self.iter_ticks()]
  File "C:\Anaconda\lib\site-packages\matplotlib\axis.py", line 881, in iter_ticks
    majorLocs = self.major.locator()
  File "C:\Anaconda\lib\site-packages\matplotlib\ticker.py", line 897, in __call__
    raise NotImplementedError('Derived must override')
NotImplementedError: Derived must override


def saveFigure(self, df, x, y, param, dim, timeBased):

        ax = plt.subplot(111)                           
        ax.bar(x, y)                          

        if hasattr(param, 'title'):
            ax.set_title(param.title)

        if hasattr(param, 'ylabel'):            
            if hasattr(param.ylabel, '__iter__') and dim < len(param.ylabel):
                ax.set_ylabel(param.ylabel[dim])
            else:
                ax.set_ylabel(param.ylabel)

        if hasattr(param, 'xlabel'):
            ax.set_xlabel(param.xlabel)        

        plt.gcf().autofmt_xdate()


        plt.savefig(param.location + os.sep + param.fileName + str(dim) + '.png')       
4

0 に答える 0