Spaces:
Build error
Build error
Commit ·
a84d625
1
Parent(s): 761ed25
Upload folder using huggingface_hub
Browse files- .DS_Store +0 -0
- app.py +105 -0
- requirements.txt +8 -0
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import yfinance as yf
|
| 5 |
+
import altair as alt
|
| 6 |
+
import plotly.figure_factory as ff
|
| 7 |
+
import pydeck as pdk
|
| 8 |
+
from vega_datasets import data as vds
|
| 9 |
+
import plotly.express as px
|
| 10 |
+
import plotly.graph_objects as go
|
| 11 |
+
from plotly.subplots import make_subplots
|
| 12 |
+
from streamlit_image_comparison import image_comparison
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def on_input_change():
|
| 16 |
+
user_input = st.session_state.user_input
|
| 17 |
+
st.session_state.past.append(user_input)
|
| 18 |
+
st.session_state.generated.append(
|
| 19 |
+
{"data": "The messages from Bot\nWith new line", "type": "normal"}
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def on_btn_click():
|
| 24 |
+
del st.session_state.past[:]
|
| 25 |
+
del st.session_state.generated[:]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def main():
|
| 29 |
+
st.title(" 3D Visualisation")
|
| 30 |
+
z_data = pd.read_csv(
|
| 31 |
+
"https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv"
|
| 32 |
+
)
|
| 33 |
+
fig = go.Figure(data=go.Surface(z=z_data, showscale=False))
|
| 34 |
+
fig.update_layout(
|
| 35 |
+
title="Mt Bruno Elevation",
|
| 36 |
+
width=400,
|
| 37 |
+
height=400,
|
| 38 |
+
margin=dict(t=40, r=0, l=20, b=20),
|
| 39 |
+
)
|
| 40 |
+
name = "default"
|
| 41 |
+
camera = dict(
|
| 42 |
+
up=dict(x=0, y=0, z=1),
|
| 43 |
+
center=dict(x=0, y=0, z=0),
|
| 44 |
+
eye=dict(x=1.25, y=1.25, z=1.25),
|
| 45 |
+
)
|
| 46 |
+
fig.update_layout(scene_camera=camera, title=name)
|
| 47 |
+
st.plotly_chart(fig)
|
| 48 |
+
df = px.data.election()
|
| 49 |
+
geojson = px.data.election_geojson()
|
| 50 |
+
fig = px.choropleth_mapbox(
|
| 51 |
+
df,
|
| 52 |
+
geojson=geojson,
|
| 53 |
+
color="Bergeron",
|
| 54 |
+
locations="district",
|
| 55 |
+
featureidkey="properties.district",
|
| 56 |
+
center={"lat": 45.5517, "lon": -73.7073},
|
| 57 |
+
mapbox_style="carto-positron",
|
| 58 |
+
zoom=9,
|
| 59 |
+
)
|
| 60 |
+
st.plotly_chart(fig)
|
| 61 |
+
fig = make_subplots(
|
| 62 |
+
rows=2,
|
| 63 |
+
cols=2,
|
| 64 |
+
specs=[
|
| 65 |
+
[{"type": "surface"}, {"type": "surface"}],
|
| 66 |
+
[{"type": "surface"}, {"type": "surface"}],
|
| 67 |
+
],
|
| 68 |
+
)
|
| 69 |
+
x = np.linspace(-5, 80, 10)
|
| 70 |
+
y = np.linspace(-5, 60, 10)
|
| 71 |
+
xGrid, yGrid = np.meshgrid(y, x)
|
| 72 |
+
z = xGrid**3 + yGrid**3
|
| 73 |
+
fig.add_trace(
|
| 74 |
+
go.Surface(x=x, y=y, z=z, colorscale="Viridis", showscale=False), row=1, col=1
|
| 75 |
+
)
|
| 76 |
+
fig.add_trace(
|
| 77 |
+
go.Surface(x=x, y=y, z=z, colorscale="RdBu", showscale=False), row=1, col=2
|
| 78 |
+
)
|
| 79 |
+
fig.add_trace(
|
| 80 |
+
go.Surface(x=x, y=y, z=z, colorscale="YlOrRd", showscale=False), row=2, col=1
|
| 81 |
+
)
|
| 82 |
+
fig.add_trace(
|
| 83 |
+
go.Surface(x=x, y=y, z=z, colorscale="YlGnBu", showscale=False), row=2, col=2
|
| 84 |
+
)
|
| 85 |
+
fig.update_layout(
|
| 86 |
+
title_text="3D subplots with different colorscales", height=800, width=800
|
| 87 |
+
)
|
| 88 |
+
st.plotly_chart(fig)
|
| 89 |
+
fig = px.scatter_3d(
|
| 90 |
+
px.data.iris(),
|
| 91 |
+
x="sepal_length",
|
| 92 |
+
y="sepal_width",
|
| 93 |
+
z="petal_width",
|
| 94 |
+
color="petal_length",
|
| 95 |
+
size="petal_length",
|
| 96 |
+
size_max=18,
|
| 97 |
+
symbol="species",
|
| 98 |
+
opacity=0.7,
|
| 99 |
+
)
|
| 100 |
+
fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
|
| 101 |
+
st.plotly_chart(fig)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
if __name__ == "__main__":
|
| 105 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
yfinance
|
| 3 |
+
streamlit-chat
|
| 4 |
+
vega_datasets
|
| 5 |
+
streamlit_image_comparison
|
| 6 |
+
plotly==5.14.1
|
| 7 |
+
altair
|
| 8 |
+
pydeck
|