Spaces:
Sleeping
Sleeping
Update pages/40_simpleline.py
Browse files- pages/40_simpleline.py +5 -5
pages/40_simpleline.py
CHANGED
@@ -2,9 +2,9 @@ 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=
|
6 |
w = st.slider('W (slope)', min_value=-10.0, max_value=10.0, value=1.0, step=0.1)
|
7 |
-
b = st.slider('B (intercept)', min_value=-
|
8 |
|
9 |
# Calculate y based on the equation y = w * x + b
|
10 |
y = w * x + b
|
@@ -14,15 +14,15 @@ fig, ax = plt.subplots(figsize=(6, 4))
|
|
14 |
fig.subplots_adjust(top=0.8, bottom=0.1)
|
15 |
|
16 |
# Plot for the y-axis (top line)
|
17 |
-
ax.hlines(1, -
|
18 |
ax.plot(y, 1, 'ro') # Plot the y point
|
19 |
|
20 |
# Plot for the x-axis (bottom line)
|
21 |
-
ax.hlines(-1, 0,
|
22 |
ax.plot(x, -1, 'ro') # Plot the x point
|
23 |
|
24 |
# Set plot limits and labels
|
25 |
-
ax.set_xlim(-
|
26 |
ax.set_ylim(-2, 2)
|
27 |
ax.set_xlabel('X-axis and Y-axis')
|
28 |
ax.set_yticks([]) # Hide y-axis ticks
|
|
|
2 |
import matplotlib.pyplot as plt
|
3 |
|
4 |
# Initialize sliders
|
5 |
+
x = st.slider('X position', min_value=0.0, max_value=100.0, value=50.0, step=1.0)
|
6 |
w = st.slider('W (slope)', min_value=-10.0, max_value=10.0, value=1.0, step=0.1)
|
7 |
+
b = st.slider('B (intercept)', min_value=-1000.0, max_value=1000.0, value=0.0, step=1.0)
|
8 |
|
9 |
# Calculate y based on the equation y = w * x + b
|
10 |
y = w * x + b
|
|
|
14 |
fig.subplots_adjust(top=0.8, bottom=0.1)
|
15 |
|
16 |
# Plot for the y-axis (top line)
|
17 |
+
ax.hlines(1, -1000, 1000, color='blue', linestyle='--') # Y-axis
|
18 |
ax.plot(y, 1, 'ro') # Plot the y point
|
19 |
|
20 |
# Plot for the x-axis (bottom line)
|
21 |
+
ax.hlines(-1, 0, 100, color='blue', linestyle='--') # X-axis
|
22 |
ax.plot(x, -1, 'ro') # Plot the x point
|
23 |
|
24 |
# Set plot limits and labels
|
25 |
+
ax.set_xlim(-1000, 1000)
|
26 |
ax.set_ylim(-2, 2)
|
27 |
ax.set_xlabel('X-axis and Y-axis')
|
28 |
ax.set_yticks([]) # Hide y-axis ticks
|