File size: 738 Bytes
1dd6aad
 
 
 
 
 
 
 
a19e34a
270150e
1dd6aad
 
 
 
9267ceb
1dd6aad
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt

# Streamlit app title
st.title('Interactive Scatter Plot with Noise and Number of Data Points')

# Sidebar sliders for noise and number of data points
noise_level = st.sidebar.slider('Noise Level', 0.0, 2.0, 0.5, step=0.01)
num_points = st.sidebar.slider('Number of Data Points', 10, 100, 50, step=5)

# Generate data
np.random.seed(0)
x = np.linspace(0, 10, num_points)
y = 2 * x + 1 + noise_level * np.random.randn(num_points)

# Create scatter plot
fig, ax = plt.subplots()
ax.scatter(x, y, alpha=0.6)
ax.set_title('Scatter Plot with Noise and Number of Data Points')
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')

# Display plot in Streamlit
st.pyplot(fig)