Skip to content

Plot.add_timeseries fails when colorbar Axes is present

Trying to add a new set of data Axes to a plot with a colorbar fails because the colorbar Axes object doesn't have the relevant geometry attributes and methods:

>>> from gwpy.timeseries import TimeSeries
>>> ts = TimeSeries.fetch('H1:LDAS-STRAIN,rds', 'September 16 2010 06:40', 'September 16 2010 06:50')
>>> specgram = ts.spectrogram(5, fftlength=2, overlap=1) ** (1/2.)
>>> plot = specgram.plot()
>>> plot.add_colorbar()
>>> plot.add_timeseries(ts, newax=True)
Traceback (most recent call last):
  File "gwpy-78.py", line 16, in <module>
    plot.add_timeseries(ts, newax=True)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/timeseries.py", line 403, in add_timeseries
    super(TimeSeriesPlot, self).add_timeseries(timeseries, **kwargs)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/decorators.py", line 41, in wrapper
    return func(artist, *args, **kwargs)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/core.py", line 604, in add_timeseries
    ax=ax, newax=newax, **kwargs)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/decorators.py", line 41, in wrapper
    return func(artist, *args, **kwargs)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/core.py", line 693, in add_array
    ax = self._add_new_axes(projection=projection)
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/core.py", line 358, in _add_new_axes
    geometry = self._increment_geometry()
  File "/Users/duncan/Library/Python/2.7/lib/python/site-packages/gwpy-0.1b1.dev46-py2.7.egg/gwpy/plotter/core.py", line 342, in _increment_geometry
    current = self.axes[-1].get_geometry()
AttributeError: 'Axes' object has no attribute 'get_geometry'