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.
jmmease
October 24, 2018, 11:54am
2
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)
jmmease
October 25, 2018, 10:17am
4
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