eaglelandsonce commited on
Commit
e2981a8
·
verified ·
1 Parent(s): 72efeaf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+
6
+ sns.set_theme(style="dark")
7
+
8
+ def generate_plot():
9
+ # Simulate data from a bivariate Gaussian
10
+ n = 10000
11
+ mean = [0, 0]
12
+ cov = [(2, .4), (.4, .2)]
13
+ rng = np.random.RandomState(0)
14
+ x, y = rng.multivariate_normal(mean, cov, n).T
15
+
16
+ # Create the plot
17
+ fig, ax = plt.subplots(figsize=(6, 6))
18
+ sns.scatterplot(x=x, y=y, s=5, color=".15", ax=ax)
19
+ sns.histplot(x=x, y=y, bins=50, pthresh=.1, cmap="mako", ax=ax)
20
+ sns.kdeplot(x=x, y=y, levels=5, color="w", linewidths=1, ax=ax)
21
+
22
+ return fig
23
+
24
+ # Gradio interface
25
+ demo = gr.Interface(
26
+ fn=generate_plot,
27
+ inputs=[],
28
+ outputs=gr.Plot(label="Bivariate Gaussian Plot"),
29
+ title="Bivariate Distribution Visualizer",
30
+ description="Generates a scatterplot, histogram, and KDE contours from a simulated bivariate Gaussian distribution."
31
+ )
32
+
33
+ demo.launch()