Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,16 +3,26 @@ import pandas as pd
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
|
| 5 |
def plot_graph(file):
|
| 6 |
-
# Read the CSV file
|
| 7 |
df = pd.read_csv(file.name)
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
plt.grid(True)
|
| 15 |
-
|
|
|
|
| 16 |
plot_filename = 'plot.png'
|
| 17 |
plt.savefig(plot_filename)
|
| 18 |
plt.close()
|
|
|
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
|
| 5 |
def plot_graph(file):
|
|
|
|
| 6 |
df = pd.read_csv(file.name)
|
| 7 |
+
|
| 8 |
+
x_axis = 'Date'
|
| 9 |
+
y_axis = 'Count'
|
| 10 |
+
group_label = 'Species'
|
| 11 |
+
|
| 12 |
+
df[x_axis] = pd.to_datetime(df[x_axis])
|
| 13 |
+
|
| 14 |
+
plt.figure(figsize=(10, 5))
|
| 15 |
+
for label, group_df in df.groupby(group_label):
|
| 16 |
+
plt.plot(group_df[x_axis], group_df[y_axis], label=label)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
plt.title(f'{y_axis} of {group_label} over {x_axis}')
|
| 20 |
+
plt.xlabel(x_axis)
|
| 21 |
+
plt.ylabel(y_axis)
|
| 22 |
+
plt.legend(title=group_label)
|
| 23 |
plt.grid(True)
|
| 24 |
+
plt.xticks(rotation=45)
|
| 25 |
+
|
| 26 |
plot_filename = 'plot.png'
|
| 27 |
plt.savefig(plot_filename)
|
| 28 |
plt.close()
|