Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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}
|
| 17 |
-
ax.set_xlabel("Length (
|
| 18 |
-
ax.set_ylabel("Width (
|
| 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
|
| 34 |
-
width = st.number_input("Enter the Width of the Plot
|
|
|
|
|
|
|
|
|
|
| 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)
|