Py.Cafe

antonymilne/

dash-plotly-iris-visualization

Visualizing Iris Flower Data with Dash and Plotly

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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import dash
from dash import dcc, html
import plotly.express as px
import plotly.io as pio
import vizro
import plotly.graph_objects as go

new_bits = go.layout.Template(data=go.layout.template.Data(
    #bar=[go.Bar(marker_pattern_shape="/")],
    #histogram=[go.Histogram(marker_pattern_shape="/")]
    histogram=[go.Histogram(fillcolor=0.8)]
))
template = pio.templates.merge_templates("vizro_light", new_bits)

print(template.data)

df = px.data.iris()

fig1 = px.scatter(
    df,
    x="sepal_length",
    y="petal_length",
    color="species",
    title="Line Chart: Petal vs Sepal Length",
    template=template,
)

fig2 = px.histogram(
    df,
    x="species",
    y="petal_width",
    color="species",
    template=template
)

print(fig2)

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

if __name__ == "__main__":
    app.run_server(debug=True)