Spaces:
Sleeping
Sleeping
Update pages/40_simpleline.py
Browse files- pages/40_simpleline.py +16 -20
pages/40_simpleline.py
CHANGED
@@ -10,28 +10,24 @@ b = st.slider('B (intercept)', min_value=-10.0, max_value=10.0, value=0.0, step=
|
|
10 |
y = w * x + b
|
11 |
|
12 |
# Create the plot
|
13 |
-
fig, ax = plt.subplots(
|
14 |
-
fig.subplots_adjust(
|
15 |
|
16 |
-
# Plot for the
|
17 |
-
ax
|
18 |
-
ax
|
19 |
-
ax[0].set_xlim(0, 10)
|
20 |
-
ax[0].set_ylim(-1, 1)
|
21 |
-
ax[0].set_xlabel('X-axis')
|
22 |
-
ax[0].set_yticks([]) # Hide y-axis ticks
|
23 |
-
ax[0].set_title('X-axis Position')
|
24 |
-
ax[0].grid(True)
|
25 |
|
26 |
-
# Plot for the
|
27 |
-
ax
|
28 |
-
ax
|
29 |
-
|
30 |
-
|
31 |
-
ax
|
32 |
-
ax
|
33 |
-
ax
|
34 |
-
ax[
|
|
|
|
|
35 |
|
36 |
# Display the plot in Streamlit
|
37 |
st.pyplot(fig)
|
|
|
10 |
y = w * x + b
|
11 |
|
12 |
# Create the plot
|
13 |
+
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, -10, 10, 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, 10, 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(-10, 10)
|
26 |
+
ax.set_ylim(-2, 2)
|
27 |
+
ax.set_xlabel('X-axis and Y-axis')
|
28 |
+
ax.set_yticks([]) # Hide y-axis ticks
|
29 |
+
ax.set_title(f'y = {w} * x + {b}')
|
30 |
+
ax.grid(True)
|
31 |
|
32 |
# Display the plot in Streamlit
|
33 |
st.pyplot(fig)
|