Update plot_graph.py
Browse files- plot_graph.py +11 -13
plot_graph.py
CHANGED
@@ -36,8 +36,7 @@ def plot_follower_comparison(author_names, dataset_path="followers-leaderboard",
|
|
36 |
else:
|
37 |
dfs = global_dataset_dfs[dataset_path]
|
38 |
|
39 |
-
plt.
|
40 |
-
ax = plt.gca()
|
41 |
valid_authors = []
|
42 |
|
43 |
for idx, author in enumerate(author_names):
|
@@ -73,23 +72,22 @@ def plot_follower_comparison(author_names, dataset_path="followers-leaderboard",
|
|
73 |
|
74 |
if not valid_authors:
|
75 |
print("No valid data found for any authors.")
|
76 |
-
return
|
77 |
|
78 |
# Plot configuration
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
# Date formatting
|
86 |
ax.xaxis.set_major_formatter(plt.matplotlib.dates.DateFormatter('%d-%m-%Y'))
|
87 |
plt.xticks(rotation=45, ha='right')
|
88 |
|
89 |
# Legend and layout
|
90 |
-
|
91 |
plt.tight_layout()
|
92 |
-
|
93 |
-
fig
|
94 |
-
|
95 |
-
return fig
|
|
|
36 |
else:
|
37 |
dfs = global_dataset_dfs[dataset_path]
|
38 |
|
39 |
+
fig, ax = plt.subplots(figsize=(14, 8)) # Create a new figure
|
|
|
40 |
valid_authors = []
|
41 |
|
42 |
for idx, author in enumerate(author_names):
|
|
|
72 |
|
73 |
if not valid_authors:
|
74 |
print("No valid data found for any authors.")
|
75 |
+
return None
|
76 |
|
77 |
# Plot configuration
|
78 |
+
ax.set_title(f'Follower Trend Comparison ({", ".join(valid_authors)})', pad=20)
|
79 |
+
ax.set_xlabel('Date', labelpad=15)
|
80 |
+
ax.set_ylabel('Followers', labelpad=15)
|
81 |
+
ax.set_ylim(bottom=0)
|
82 |
+
ax.grid(True, alpha=0.25)
|
83 |
|
84 |
# Date formatting
|
85 |
ax.xaxis.set_major_formatter(plt.matplotlib.dates.DateFormatter('%d-%m-%Y'))
|
86 |
plt.xticks(rotation=45, ha='right')
|
87 |
|
88 |
# Legend and layout
|
89 |
+
ax.legend(loc='upper left', bbox_to_anchor=(1, 1), framealpha=0.9)
|
90 |
plt.tight_layout()
|
91 |
+
|
92 |
+
return fig # Return the figure instead of plt
|
93 |
+
|
|