Spaces:
Sleeping
Sleeping
eaglelandsonce
commited on
Update pages/40_simpleline.py
Browse files- pages/40_simpleline.py +21 -11
pages/40_simpleline.py
CHANGED
@@ -10,18 +10,28 @@ 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(figsize=(6,
|
14 |
-
|
15 |
-
ax.hlines(0, 0, 10, color='blue', linestyle='--') # Second horizontal line
|
16 |
-
ax.plot([x], [y], 'ro') # Plot the point
|
17 |
|
18 |
-
#
|
19 |
-
ax.
|
20 |
-
ax.
|
21 |
-
ax.
|
22 |
-
ax.
|
23 |
-
ax.
|
24 |
-
ax.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# Display the plot in Streamlit
|
27 |
st.pyplot(fig)
|
|
|
10 |
y = w * x + b
|
11 |
|
12 |
# Create the plot
|
13 |
+
fig, ax = plt.subplots(2, 1, figsize=(6, 4), gridspec_kw={'height_ratios': [1, 1]})
|
14 |
+
fig.subplots_adjust(hspace=0.5)
|
|
|
|
|
15 |
|
16 |
+
# Plot for the x-axis
|
17 |
+
ax[0].hlines(0, 0, 10, color='blue', linestyle='--') # X-axis
|
18 |
+
ax[0].plot(x, 0, 'ro') # Plot the x point
|
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 y-axis
|
27 |
+
ax[1].hlines(0, -10, 10, color='blue', linestyle='--') # Y-axis
|
28 |
+
ax[1].plot(y, 0, 'ro') # Plot the y point
|
29 |
+
ax[1].set_xlim(-10, 10)
|
30 |
+
ax[1].set_ylim(-1, 1)
|
31 |
+
ax[1].set_xlabel('Y-axis')
|
32 |
+
ax[1].set_yticks([]) # Hide y-axis ticks
|
33 |
+
ax[1].set_title(f'y = {w} * x + {b}')
|
34 |
+
ax[1].grid(True)
|
35 |
|
36 |
# Display the plot in Streamlit
|
37 |
st.pyplot(fig)
|