Show Sidebar Hide Sidebar

Multiple Chart Types in Python

How to design figures with multiple chart types in python.

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!

Line Chart and a Bar Chart

In [1]:
import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scatter(
    x=[0, 1, 2, 3, 4, 5],
    y=[1.5, 1, 1.3, 0.7, 0.8, 0.9]
)
trace2 = go.Bar(
    x=[0, 1, 2, 3, 4, 5],
    y=[1, 0.5, 0.7, -1.2, 0.3, 0.4]
)

data = [trace1, trace2]
py.iplot(data, filename='bar-line')
Out[1]:

A Contour and Scatter Plot of the Method of Steepest Descent

In [2]:
import plotly.plotly as py
import plotly.graph_objs as go

import json
import six.moves.urllib

response = six.moves.urllib.request.urlopen('https://raw.githubusercontent.com/plotly/datasets/master/steepest.json')
data = json.load(response)

trace1 = go.Contour(
    z=data['contour_z'][0],
    y=data['contour_y'][0],
    x=data['contour_x'][0],
    ncontours=30,
    showscale=False
)
trace2 = go.Scatter(
    x=data['trace_x'],
    y=data['trace_y'],
    mode='markers+lines',
    name='steepest',
    line=dict(
        color='black'
    )
)

data = [trace1, trace2]
py.iplot(data, filename='contour-scatter')
Out[2]:

Reference

See https://plot.ly/python/reference/ for more information and attribute options!

Still need help?
Contact Us

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