Spaces:
Sleeping
Sleeping
File size: 927 Bytes
e2981a8 | 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 | import gradio as gr
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="dark")
def generate_plot():
# Simulate data from a bivariate Gaussian
n = 10000
mean = [0, 0]
cov = [(2, .4), (.4, .2)]
rng = np.random.RandomState(0)
x, y = rng.multivariate_normal(mean, cov, n).T
# Create the plot
fig, ax = plt.subplots(figsize=(6, 6))
sns.scatterplot(x=x, y=y, s=5, color=".15", ax=ax)
sns.histplot(x=x, y=y, bins=50, pthresh=.1, cmap="mako", ax=ax)
sns.kdeplot(x=x, y=y, levels=5, color="w", linewidths=1, ax=ax)
return fig
# Gradio interface
demo = gr.Interface(
fn=generate_plot,
inputs=[],
outputs=gr.Plot(label="Bivariate Gaussian Plot"),
title="Bivariate Distribution Visualizer",
description="Generates a scatterplot, histogram, and KDE contours from a simulated bivariate Gaussian distribution."
)
demo.launch() |