awacke1 commited on
Commit
37fa554
·
1 Parent(s): 8c1e39c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +138 -0
app.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+ from mpl_toolkits.mplot3d import Axes3D
6
+
7
+ # Sidebar
8
+ st.sidebar.header("Select Visualization")
9
+ plot_type = st.sidebar.selectbox("Choose a plot type", ("Heatmap", "3D Heatmap", "Contour", "Quiver", "Contourf", "Streamplot", "Hexbin", "Eventplot", "Tricontour", "Triplot", "3D Voxel"))
10
+
11
+ # Load Data
12
+ data = pd.read_csv("healthcare_treatments.csv")
13
+
14
+ # Define Functions for each plot type
15
+ def heatmap():
16
+ fig, ax = plt.subplots()
17
+ ax.set_title("Top Health Care Treatments")
18
+ heatmap_data = np.random.rand(10, 10)
19
+ im = ax.imshow(heatmap_data, cmap="YlOrRd")
20
+ plt.colorbar(im, ax=ax)
21
+ st.pyplot(fig)
22
+
23
+ def heatmap_3d():
24
+ fig = plt.figure()
25
+ ax = fig.add_subplot(111, projection='3d')
26
+ ax.set_title("Top Health Care Treatments")
27
+ x, y = np.meshgrid(range(10), range(10))
28
+ z = np.random.rand(10, 10)
29
+ ax.plot_surface(x, y, z, cmap="YlOrRd")
30
+ st.pyplot(fig)
31
+
32
+ def contour():
33
+ fig, ax = plt.subplots()
34
+ ax.set_title("Top Health Care Treatments")
35
+ x = np.linspace(-3, 3, 100)
36
+ y = np.linspace(-3, 3, 100)
37
+ X, Y = np.meshgrid(x, y)
38
+ Z = np.sin(np.sqrt(X**2 + Y**2))
39
+ ax.contour(X, Y, Z, cmap="YlOrRd")
40
+ st.pyplot(fig)
41
+
42
+ def quiver():
43
+ fig, ax = plt.subplots()
44
+ ax.set_title("Top Health Care Treatments")
45
+ x = np.arange(-2, 2, 0.2)
46
+ y = np.arange(-2, 2, 0.2)
47
+ X, Y = np.meshgrid(x, y)
48
+ U = np.cos(X)
49
+ V = np.sin(Y)
50
+ ax.quiver(X, Y, U, V)
51
+ st.pyplot(fig)
52
+
53
+ def contourf():
54
+ fig, ax = plt.subplots()
55
+ ax.set_title("Top Health Care Treatments")
56
+ x = np.linspace(-3, 3, 100)
57
+ y = np.linspace(-3, 3, 100)
58
+ X, Y = np.meshgrid(x, y)
59
+ Z = np.sin(np.sqrt(X**2 + Y**2))
60
+ ax.contourf(X, Y, Z, cmap="YlOrRd")
61
+ st.pyplot(fig)
62
+
63
+ def streamplot():
64
+ fig, ax = plt.subplots()
65
+ ax.set_title("Top Health Care Treatments")
66
+ x, y = np.linspace(-3, 3, 100), np.linspace(-3, 3, 100)
67
+ X, Y = np.meshgrid(x, y)
68
+ U = -1 - X**2 + Y
69
+ V = 1 + X - Y**2
70
+ ax.streamplot(X, Y, U, V, density=[0.5, 1], cmap="YlOrRd")
71
+ st.pyplot(fig)
72
+
73
+ def hexbin():
74
+ fig, ax = plt.subplots()
75
+ ax.set_title("Top Health Care Treatments")
76
+ x = np.random.normal(0, 1, 1000)
77
+ y = np.random.normal(0, 1, 1000)
78
+ ax.hexbin(x, y, gridsize=20, cmap="YlOrRd")
79
+ st.pyplot(fig)
80
+
81
+ def eventplot():
82
+ fig, ax = plt.subplots()
83
+ ax.set_title("Top Health Care Treatments")
84
+ data = np.random.rand(10, 10) > 0.5
85
+ ax.eventplot(np.where(data))
86
+ st.pyplot(fig)
87
+
88
+ def tricontour():
89
+ fig, ax = plt.subplots()
90
+ ax.set_title("Top Health Care Treatments")
91
+ x = np.random.rand(10)
92
+ y = np.random.rand(10)
93
+ z = np.random.rand(10)
94
+ ax.tricontour(x, y, z, cmap="YlOrRd")
95
+ st.pyplot(fig)
96
+
97
+ def triplot():
98
+ fig, ax = plt.subplots()
99
+ ax.set_title("Top Health Care Treatments")
100
+ x = np.random.rand(10)
101
+ y = np.random.rand(10)
102
+ tri = np.random.randint(0, 10, (10, 3))
103
+ ax.triplot(x, y, tri)
104
+ st.pyplot(fig)
105
+
106
+ def voxel():
107
+ fig = plt.figure()
108
+ ax = fig.gca(projection='3d')
109
+ ax.set_title("Top Health Care Treatments")
110
+ x, y, z = np.indices((8, 8, 8))
111
+ voxels = (x < 4) & (y < 4) & (z < 4)
112
+ ax.voxels(voxels, facecolors='YlOrRd', edgecolor='k')
113
+ st.pyplot(fig)
114
+
115
+ st.title("Top Health Care Treatments Visualizations")
116
+
117
+ if plot_type == "Heatmap":
118
+ heatmap()
119
+ elif plot_type == "3D Heatmap":
120
+ heatmap_3d()
121
+ elif plot_type == "Contour":
122
+ contour()
123
+ elif plot_type == "Quiver":
124
+ quiver()
125
+ elif plot_type == "Contourf":
126
+ contourf()
127
+ elif plot_type == "Streamplot":
128
+ streamplot()
129
+ elif plot_type == "Hexbin":
130
+ hexbin()
131
+ elif plot_type == "Eventplot":
132
+ eventplot()
133
+ elif plot_type == "Tricontour":
134
+ tricontour()
135
+ elif plot_type == "Triplot":
136
+ triplot()
137
+ elif plot_type == "3D Voxel":
138
+ voxel()