Py.Cafe

antonymilne/

plotly-express-colors

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

import plotly.express as px
import plotly.io as pio
import plotly.graph_objects as go

histogram_colors = ["orange", "purple", "grey"]

histogram_template = go.layout.Template(
    data={"histogram": [{"marker": {"color": histogram_colors}}]}
)

template = pio.templates.merge_templates("plotly", histogram_template)

df = px.data.iris()

fig1 = px.scatter(df, x="sepal_length", y="petal_length", color="species", template=template)
fig2 = px.histogram(df, color="species", template=template)

import dash
app = dash.Dash(__name__)
app.layout = [dash.dcc.Graph(figure=fig1), dash.dcc.Graph(figure=fig2)]