File size: 5,433 Bytes
37fa554
 
 
 
 
 
 
 
65e12a6
37fa554
 
318fee2
37fa554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28e4b29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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()


st.markdown("""
# 📈 Discover the Power of Matplotlib: A Tutorial to Create Stunning Visualizations in Python 🐍

Python enthusiasts and data scientists, rejoice! Our new Matplotlib tutorial will teach you how to create professional-quality visualizations to take your data analysis to the next level.

## 🎨 Versatile Library for Creating Charts and Graphs

Matplotlib is a powerful and versatile library that enables you to create a wide range of charts and graphs with ease. From heatmaps to 3D visualizations, our tutorial covers 10 different types of plots, allowing you to choose the perfect one for your data.

## 🚀 Interactive Visualizations with Streamlit

In this tutorial, you'll learn how to use Matplotlib with Streamlit to interactively display your visualizations, making it easy to share your work with others. Our step-by-step guide is designed to be accessible to beginners, while also providing advanced techniques for more experienced users.

## 💻 Lots of Code Examples and Images

With lots of code examples and images, our tutorial will guide you through creating heatmaps, contour plots, quiver plots, and many more. You'll also learn how to customize your visualizations with color maps and labels, and how to create 3D plots that showcase your data in a whole new dimension.

## 🎓 For Everyone, from Beginners to Experts

Whether you're a data analyst, a data scientist, or simply looking to add data visualization skills to your repertoire, our Matplotlib tutorial has something for everyone. So don't wait any longer to unleash the power of Matplotlib and create stunning visualizations that bring your data to life.

""")