1TSnakers commited on
Commit
1d44efc
·
verified ·
1 Parent(s): 0509790

Create src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +42 -0
src/streamlit_app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import altair as alt
2
+ import numpy as np
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+ """
7
+ # Welcome to Streamlit!
8
+
9
+ This was taken from the Streamlit docker template. this is not my code, that honor goes to the HF team
10
+
11
+ Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
12
+ If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
13
+ forums](https://discuss.streamlit.io).
14
+
15
+ In the meantime, below is an example of what you can do with just a few lines of code:
16
+ """
17
+
18
+ num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
19
+ num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
20
+
21
+ indices = np.linspace(0, 1, num_points)
22
+ theta = 2 * np.pi * num_turns * indices
23
+ radius = indices
24
+
25
+ x = radius * np.cos(theta)
26
+ y = radius * np.sin(theta)
27
+
28
+ df = pd.DataFrame({
29
+ "x": x,
30
+ "y": y,
31
+ "idx": indices,
32
+ "rand": np.random.randn(num_points),
33
+ })
34
+
35
+ st.altair_chart(alt.Chart(df, height=700, width=700)
36
+ .mark_point(filled=True)
37
+ .encode(
38
+ x=alt.X("x", axis=None),
39
+ y=alt.Y("y", axis=None),
40
+ color=alt.Color("idx", legend=None, scale=alt.Scale()),
41
+ size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
42
+ ))