eaglelandsonce commited on
Commit
5ae9492
·
verified ·
1 Parent(s): e73dca0

Update pages/40_simpleline.py

Browse files
Files changed (1) hide show
  1. 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(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)
 
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)