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