Spaces:
Sleeping
Sleeping
Update pages/40_simpleline.py
Browse files- pages/40_simpleline.py +5 -6
pages/40_simpleline.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
import matplotlib.pyplot as plt
|
3 |
-
import numpy as np
|
4 |
|
5 |
# Initialize sliders
|
6 |
x = st.slider('X position', min_value=0.0, max_value=10.0, value=5.0, step=0.1)
|
@@ -11,10 +10,10 @@ b = st.slider('B (intercept)', min_value=-10.0, max_value=10.0, value=0.0, step=
|
|
11 |
y = w * x + b
|
12 |
|
13 |
# Create the plot
|
14 |
-
fig, ax = plt.subplots()
|
15 |
-
ax.axhline(y=2, color='
|
16 |
-
ax.axhline(y=-2, color='
|
17 |
-
ax.plot(x, y, 'ro') # Plot the point
|
18 |
|
19 |
# Set plot limits and labels
|
20 |
ax.set_xlim(0, 10)
|
@@ -25,4 +24,4 @@ ax.set_title(f'y = {w} * x + {b}')
|
|
25 |
ax.grid(True)
|
26 |
|
27 |
# Display the plot in Streamlit
|
28 |
-
st.pyplot(fig)
|
|
|
1 |
import streamlit as st
|
2 |
import matplotlib.pyplot as plt
|
|
|
3 |
|
4 |
# Initialize sliders
|
5 |
x = st.slider('X position', min_value=0.0, max_value=10.0, value=5.0, step=0.1)
|
|
|
10 |
y = w * x + b
|
11 |
|
12 |
# Create the plot
|
13 |
+
fig, ax = plt.subplots(figsize=(6, 4))
|
14 |
+
ax.axhline(y=2, color='blue', linestyle='--') # First horizontal line
|
15 |
+
ax.axhline(y=-2, color='blue', linestyle='--') # Second horizontal line
|
16 |
+
ax.plot([x], [y], 'ro') # Plot the point
|
17 |
|
18 |
# Set plot limits and labels
|
19 |
ax.set_xlim(0, 10)
|
|
|
24 |
ax.grid(True)
|
25 |
|
26 |
# Display the plot in Streamlit
|
27 |
+
st.pyplot(fig)
|