Show Sidebar Hide Sidebar

Mulitple Axes in Pandas

How to create a chart with multiple axes with Pandas in Plotly.

New to Plotly?

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Note: Parallel Coordinates Plots are available in version 2.0.6+
Run pip install plotly --upgrade to update your Plotly version.

In [3]:
import plotly
plotly.__version__
Out[3]:
'2.0.7'

Imports

In [2]:
import plotly.plotly as py
import cufflinks as cf

print cf.__version__
0.8.2

Simple Secondary Y Axis with secondary_y

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

df.iplot(secondary_y=['c', 'd'], filename='pandas/secondary y')
Out[4]:

Secondary Y Axis with Multiple Chart Types

In [5]:
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'])
py.iplot(fig2, filename='pandas/secondary y with bar chart')
Out[5]:
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.