Black Lives Matter. Please consider donating to Black Girls Code today.
https://www.blackgirlscode.com/

# Multiple Chart Types in Python

How to design figures with multiple chart types in python.

New to Plotly?

Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

#### Line Chart and a Bar Chart¶

In :
import plotly.graph_objects as go

fig = go.Figure()

go.Scatter(
x=[0, 1, 2, 3, 4, 5],
y=[1.5, 1, 1.3, 0.7, 0.8, 0.9]
))

go.Bar(
x=[0, 1, 2, 3, 4, 5],
y=[1, 0.5, 0.7, -1.2, 0.3, 0.4]
))

fig.show()


#### A Contour and Scatter Plot of the Method of Steepest Descent¶

In :
import plotly.graph_objects as go

import json
import six.moves.urllib

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

# Create figure
fig = go.Figure()

go.Contour(
z=data["contour_z"],
y=data["contour_y"],
x=data["contour_x"],
ncontours=30,
showscale=False
)
)

go.Scatter(
x=data["trace_x"],
y=data["trace_y"],
mode="markers+lines",
name="steepest",
line=dict(
color="black"
)
)
)

fig.show()


#### Reference¶

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.

Learn about how to install Dash at https://dash.plot.ly/installation.

Everywhere in this page that you see fig.show(), you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or any Plotly Express function e.g. px.bar(...)
# fig.update_layout( ... )

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
dcc.Graph(figure=fig)
]) 