ZachGF commited on
Commit
f5d1103
·
verified ·
1 Parent(s): a30008c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
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
- # Generate a simple plot
9
- plt.figure()
10
- df.plot()
11
- plt.title('Graph of Tabular Data')
12
- plt.xlabel('X-axis')
13
- plt.ylabel('Y-axis')
 
 
 
 
 
 
 
 
 
 
14
  plt.grid(True)
15
- # Save the plot to a file
 
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()