-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
38 lines (28 loc) · 875 Bytes
/
Copy pathplot.py
File metadata and controls
38 lines (28 loc) · 875 Bytes
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
import streamlit as st
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def f1(t):
return np.exp(-t) * np.cos(2*np.pi*t)
def f2(t):
return np.cos(2*np.pi*t)
t = np.arange(0.0, 5.0, 0.1)
def table():
st.header('Tables')
c1, c2 = st.columns(2)
c1.write(pd.DataFrame([x for x in zip(t,f1(t))]))
c2.write(pd.DataFrame([x for x in zip(t,f2(t))]))
def plot():
plt.figure()
plt.subplot(2, 1, 1) # nrows, ncols, index
plt.plot(t, f1(t), 'bo', t, f1(t), 'k')
plt.subplot(212)
plt.plot(t, f2(t), 'r--')
st.header('Charts')
st.pyplot(plt)
st.title('Data Explorer')
st.sidebar.header('Settings')
actions = {'Tabulate': table, 'Plot': plot}
choices = st.sidebar.multiselect('Choose task:', ['Tabulate', 'Plot'])
for choice in choices:
result = actions[choice]()