File size: 3,766 Bytes
37fa554
 
 
 
 
 
 
 
65e12a6
37fa554
 
318fee2
37fa554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65e12a6
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Sidebar
st.sidebar.header("Select Visualization")
plot_type = st.sidebar.selectbox("Choose a plot type", ("Heatmap", "3D Heatmap", "Contour", "Quiver", "Contourf", "Streamplot", "Hexbin", "Eventplot", "Tricontour", "Triplot"))

# Load Data
# data = pd.read_csv("healthcare_treatments.csv")

# Define Functions for each plot type
def heatmap():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    heatmap_data = np.random.rand(10, 10)
    im = ax.imshow(heatmap_data, cmap="YlOrRd")
    plt.colorbar(im, ax=ax)
    st.pyplot(fig)

def heatmap_3d():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.set_title("Top Health Care Treatments")
    x, y = np.meshgrid(range(10), range(10))
    z = np.random.rand(10, 10)
    ax.plot_surface(x, y, z, cmap="YlOrRd")
    st.pyplot(fig)

def contour():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.linspace(-3, 3, 100)
    y = np.linspace(-3, 3, 100)
    X, Y = np.meshgrid(x, y)
    Z = np.sin(np.sqrt(X**2 + Y**2))
    ax.contour(X, Y, Z, cmap="YlOrRd")
    st.pyplot(fig)

def quiver():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.arange(-2, 2, 0.2)
    y = np.arange(-2, 2, 0.2)
    X, Y = np.meshgrid(x, y)
    U = np.cos(X)
    V = np.sin(Y)
    ax.quiver(X, Y, U, V)
    st.pyplot(fig)

def contourf():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.linspace(-3, 3, 100)
    y = np.linspace(-3, 3, 100)
    X, Y = np.meshgrid(x, y)
    Z = np.sin(np.sqrt(X**2 + Y**2))
    ax.contourf(X, Y, Z, cmap="YlOrRd")
    st.pyplot(fig)

def streamplot():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x, y = np.linspace(-3, 3, 100), np.linspace(-3, 3, 100)
    X, Y = np.meshgrid(x, y)
    U = -1 - X**2 + Y
    V = 1 + X - Y**2
    ax.streamplot(X, Y, U, V, density=[0.5, 1], cmap="YlOrRd")
    st.pyplot(fig)

def hexbin():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.random.normal(0, 1, 1000)
    y = np.random.normal(0, 1, 1000)
    ax.hexbin(x, y, gridsize=20, cmap="YlOrRd")
    st.pyplot(fig)

def eventplot():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    data = np.random.rand(10, 10) > 0.5
    ax.eventplot(np.where(data))
    st.pyplot(fig)

def tricontour():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.random.rand(10)
    y = np.random.rand(10)
    z = np.random.rand(10)
    ax.tricontour(x, y, z, cmap="YlOrRd")
    st.pyplot(fig)

def triplot():
    fig, ax = plt.subplots()
    ax.set_title("Top Health Care Treatments")
    x = np.random.rand(10)
    y = np.random.rand(10)
    tri = np.random.randint(0, 10, (10, 3))
    ax.triplot(x, y, tri)
    st.pyplot(fig)

def voxel():
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.set_title("Top Health Care Treatments")
    x, y, z = np.indices((8, 8, 8))
    voxels = (x < 4) & (y < 4) & (z < 4)
    ax.voxels(voxels, facecolors='YlOrRd', edgecolor='k')
    st.pyplot(fig)

st.title("Top Health Care Treatments Visualizations")

if plot_type == "Heatmap":
    heatmap()
elif plot_type == "3D Heatmap":
    heatmap_3d()
elif plot_type == "Contour":
    contour()
elif plot_type == "Quiver":
    quiver()
elif plot_type == "Contourf":
    contourf()
elif plot_type == "Streamplot":
    streamplot()
elif plot_type == "Hexbin":
    hexbin()
elif plot_type == "Eventplot":
    eventplot()
elif plot_type == "Tricontour":
    tricontour()
elif plot_type == "Triplot":
    triplot()