ahsangahothi commited on
Commit
9d01bc5
·
verified ·
1 Parent(s): 54efad8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
3
  import numpy as np
4
 
5
  # Function to draw the plot
6
- def draw_plot(length, width):
7
  fig, ax = plt.subplots(figsize=(8, 8))
8
 
9
  # Plotting the plot as a rectangle
@@ -13,9 +13,9 @@ def draw_plot(length, width):
13
  ax.plot([length, length], [0, width], color="blue") # Right side
14
 
15
  # Adding labels and title
16
- ax.set_title(f"Plot: Length = {length} units, Width = {width} units")
17
- ax.set_xlabel("Length (units)")
18
- ax.set_ylabel("Width (units)")
19
 
20
  # Set the limits
21
  ax.set_xlim(0, length + 10)
@@ -29,13 +29,16 @@ def draw_plot(length, width):
29
  # Streamlit interface
30
  st.title("Plot Drawing App")
31
 
32
- # User input for plot dimensions
33
- length = st.number_input("Enter the Length of the Plot (in units)", min_value=1, max_value=1000, value=50)
34
- width = st.number_input("Enter the Width of the Plot (in units)", min_value=1, max_value=1000, value=30)
 
 
 
35
 
36
  # Draw the plot when inputs are provided
37
  if length and width:
38
- fig = draw_plot(length, width)
39
 
40
  # Display the plot
41
  st.pyplot(fig)
 
3
  import numpy as np
4
 
5
  # Function to draw the plot
6
+ def draw_plot(length, width, unit):
7
  fig, ax = plt.subplots(figsize=(8, 8))
8
 
9
  # Plotting the plot as a rectangle
 
13
  ax.plot([length, length], [0, width], color="blue") # Right side
14
 
15
  # Adding labels and title
16
+ ax.set_title(f"Plot: Length = {length} {unit}, Width = {width} {unit}")
17
+ ax.set_xlabel(f"Length ({unit})")
18
+ ax.set_ylabel(f"Width ({unit})")
19
 
20
  # Set the limits
21
  ax.set_xlim(0, length + 10)
 
29
  # Streamlit interface
30
  st.title("Plot Drawing App")
31
 
32
+ # User input for plot dimensions and units
33
+ length = st.number_input("Enter the Length of the Plot", min_value=1, max_value=1000, value=50)
34
+ width = st.number_input("Enter the Width of the Plot", min_value=1, max_value=1000, value=30)
35
+
36
+ # Dropdown menu for unit selection
37
+ unit = st.selectbox("Select Unit", ["ft", "m", "cm"])
38
 
39
  # Draw the plot when inputs are provided
40
  if length and width:
41
+ fig = draw_plot(length, width, unit)
42
 
43
  # Display the plot
44
  st.pyplot(fig)