File size: 2,977 Bytes
a84d625
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import streamlit as st
import pandas as pd
import numpy as np
import yfinance as yf
import altair as alt
import plotly.figure_factory as ff
import pydeck as pdk
from vega_datasets import data as vds
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from streamlit_image_comparison import image_comparison


def on_input_change():
    user_input = st.session_state.user_input
    st.session_state.past.append(user_input)
    st.session_state.generated.append(
        {"data": "The messages from Bot\nWith new line", "type": "normal"}
    )


def on_btn_click():
    del st.session_state.past[:]
    del st.session_state.generated[:]


def main():
    st.title(" 3D Visualisation")
    z_data = pd.read_csv(
        "https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv"
    )
    fig = go.Figure(data=go.Surface(z=z_data, showscale=False))
    fig.update_layout(
        title="Mt Bruno Elevation",
        width=400,
        height=400,
        margin=dict(t=40, r=0, l=20, b=20),
    )
    name = "default"
    camera = dict(
        up=dict(x=0, y=0, z=1),
        center=dict(x=0, y=0, z=0),
        eye=dict(x=1.25, y=1.25, z=1.25),
    )
    fig.update_layout(scene_camera=camera, title=name)
    st.plotly_chart(fig)
    df = px.data.election()
    geojson = px.data.election_geojson()
    fig = px.choropleth_mapbox(
        df,
        geojson=geojson,
        color="Bergeron",
        locations="district",
        featureidkey="properties.district",
        center={"lat": 45.5517, "lon": -73.7073},
        mapbox_style="carto-positron",
        zoom=9,
    )
    st.plotly_chart(fig)
    fig = make_subplots(
        rows=2,
        cols=2,
        specs=[
            [{"type": "surface"}, {"type": "surface"}],
            [{"type": "surface"}, {"type": "surface"}],
        ],
    )
    x = np.linspace(-5, 80, 10)
    y = np.linspace(-5, 60, 10)
    xGrid, yGrid = np.meshgrid(y, x)
    z = xGrid**3 + yGrid**3
    fig.add_trace(
        go.Surface(x=x, y=y, z=z, colorscale="Viridis", showscale=False), row=1, col=1
    )
    fig.add_trace(
        go.Surface(x=x, y=y, z=z, colorscale="RdBu", showscale=False), row=1, col=2
    )
    fig.add_trace(
        go.Surface(x=x, y=y, z=z, colorscale="YlOrRd", showscale=False), row=2, col=1
    )
    fig.add_trace(
        go.Surface(x=x, y=y, z=z, colorscale="YlGnBu", showscale=False), row=2, col=2
    )
    fig.update_layout(
        title_text="3D subplots with different colorscales", height=800, width=800
    )
    st.plotly_chart(fig)
    fig = px.scatter_3d(
        px.data.iris(),
        x="sepal_length",
        y="sepal_width",
        z="petal_width",
        color="petal_length",
        size="petal_length",
        size_max=18,
        symbol="species",
        opacity=0.7,
    )
    fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
    st.plotly_chart(fig)


if __name__ == "__main__":
    main()