Multiple axis example does not work for cufflinks version 0.14.4 plotly version 3.3.0

I noticed that some of my code using the older version of cufflinks(0.12.1) and plotly(2.5.1) no longer works. So I try to rerun the code as in the example to see if I can reproduce the problem.
For this code here:

from plotly.offline import iplot
import cufflinks as cf
cf.set_config_file(offline=True)
%matplotlib inline

df=cf.datagen.lines(4,mode='abc')
df[['c','d']]=df[['c','d']]*100

#df.iplot(secondary_y=['c', 'd'])
fig1 = df.iplot(columns=['a', 'b'], asFigure=True)
fig2 = df.iplot(columns=['c', 'd'], kind='bar', secondary_y=['c', 'd'], asFigure=True)
fig2['data'].extend(fig1['data'])
iplot(fig2)

The code will give me AttributeError delitem

Also, the fig2[โ€˜dataโ€™] is now a tuple instead of a list, I can no longer use fig2[โ€˜dataโ€™].extend(fig1[โ€˜dataโ€™]).

Since many of my multiple y_axis codes are written as in the example, how can I rewrite my code so it will run for the latest version?

Thanks in advance.

Hi @chainster_mike,

I canโ€™t speak to the AttributeError: youโ€™re seeing inside cufflinks, thatโ€™s something that would need to be addressed in the cufflinks project (https://github.com/santosjorge/cufflinks).

For your second question, you can replace

fig2['data'].extend(fig1['data'])

with

fig2['data'] += fig1['data']

Hope that helps!
-Jon

1 Like

Thanks for the reply. I have changed to code as you suggested, but still get an error message:

from plotly.offline import iplot
import cufflinks as cf
cf.set_config_file(offline=True)
%matplotlib inline

df=cf.datagen.lines(4,mode='abc')
df[['c','d']]=df[['c','d']]

fig1 = df.iplot(columns=['a', 'b'], asFigure=True)
fig2 = df.iplot(columns=['c', 'd'], kind='bar', asFigure=True)
fig2['data'] += fig1['data']
iplot(fig2)

Screenshot%20from%202018-10-25%2009-36-53

My mistake,

Replace

fig2['data'] += fig1['data']

with

fig2.add_traces(fig1['data'])

The += syntax works on other array types that used to be lists (e.g. fig.layout.annotations += [...], but not on fig.data at the moment.)

-Jon