[SciPy-User] Separate scales for left and right axis broken

Christopher Peters cpeters at edisonmission.com
Wed Apr 13 16:03:49 EDT 2011


All, 

I am trying to run the code at 
http://pytseries.sourceforge.net/lib.plotting.examples.html#separate-scales-for-left-and-right-axis 
to generate separate scales for left and right axes for tsplot in 
scikits.timeseries.lib.plotlib, but I am getting an error. 

Package versions: 
Numpy:  1.5.1 
Matplotlib:  1.0.1 
Scikits Timeseries:  0.91.3 


Code to test: 

import numpy as np 
print np.__version__ 
import numpy.ma as ma 
import matplotlib.pyplot as plt 
print matplotlib.__version__ 
import scikits.timeseries as ts 
print ts.__version__ 
import scikits.timeseries.lib.plotlib as tpl 

# generate some random data 
data1 = np.cumprod(1 + np.random.normal(0, 1, 300)/100) 
data2 = np.cumprod(1 + np.random.normal(0, 1, 300)/100)*100 
start_date = ts.Date(freq='M', year=1982, month=1) 
series1 = ts.time_series(data1, start_date=start_date-50) 
series2 = ts.time_series(data2, start_date=start_date) 
fig = tpl.tsfigure() 
fsp = fig.add_tsplot(111) 
# plot series on left axis 
fsp.tsplot(series1, 'b-', label='<- left series') 
fsp.set_ylim(ma.min(series1.series), ma.max(series1.series)) 
# create right axis 
fsp_right = fsp.add_yaxis(position='right', yscale='log') 
# plot series on right axis 
fsp_right.tsplot(series2, 'r-', label='-> right series') 
fsp_right.set_ylim(ma.min(series2.series), ma.max(series2.series)) 
# setup legend 
fsp.legend( 
    (fsp.lines[-1], fsp_right.lines[-1]), 
    (fsp.lines[-1].get_label(), fsp_right.lines[-1].get_label()), 
) 
plt.show() 

Traceback (most recent call last): 
  File "<pyshell#75>", line 23, in <module> 
    fsp_right = fsp.add_yaxis(position='right', yscale='log') 
  File "C:\Python27\lib\site-packages\scikits\timeseries\lib\plotlib.py", 
line 1196, in add_yaxis 
    fsp_alt_args = (fsp._rows, fsp._cols, fsp._num + 1) 
AttributeError: 'TimeSeriesPlot' object has no attribute '_rows' 

My guess is that the newest version of matplotlib (1.0.1) removed the 
_rows (_cols, and _num as well) attribute for the Subplot base class, but 
this was not propagated to plotlib.py.  Looking at the revision log at 
http://projects.scipy.org/scikits/log/trunk/timeseries/scikits/timeseries/lib/plotlib.py
, it appears that 20 months ago there were some fixes for matplotlib 
version 0.99.0. 

It seems that this question was already posed by Dave Hirschfeld on 2010 
Nov 8 (a post entitled "TimeSeries Plotting Broken?" at 
http://permalink.gmane.org/gmane.comp.python.scientific.devel/14645), but 
there were no replies. 

Any help on this would be greatly appreciated! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110413/d768954d/attachment.html>


More information about the SciPy-User mailing list