Spaces:
Running
Running
Update analytics_fetch_and_rendering.py
Browse files- analytics_fetch_and_rendering.py +21 -10
analytics_fetch_and_rendering.py
CHANGED
@@ -241,18 +241,29 @@ def plot_interaction_metrics(data):
|
|
241 |
clicks_pp = [d["clicks_per_post"] for d in data]
|
242 |
comment_share = [d["comment_share_of_engagement"] for d in data]
|
243 |
|
244 |
-
fig,
|
245 |
-
|
246 |
-
ax.plot(months, shares_pp, label="Shares/Post", marker="s", color="#ff7f0e")
|
247 |
-
ax.plot(months, clicks_pp, label="Clicks/Post", marker="^", color="#2ca02c")
|
248 |
-
ax.plot(months, comment_share, label="Comment Share of Engagement (%)", marker="x", linestyle="--", color="#d62728")
|
249 |
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
plt.tight_layout()
|
254 |
-
return fig
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
|
258 |
def fetch_and_render_analytics(client_id, token):
|
|
|
241 |
clicks_pp = [d["clicks_per_post"] for d in data]
|
242 |
comment_share = [d["comment_share_of_engagement"] for d in data]
|
243 |
|
244 |
+
fig, axes = plt.subplots(nrows=4, ncols=1, figsize=(12, 10), sharex=True)
|
245 |
+
fig.suptitle("Post Interaction Metrics", fontsize=16)
|
|
|
|
|
|
|
246 |
|
247 |
+
axes[0].plot(months, comments_pp, marker="o", color="#1f77b4")
|
248 |
+
axes[0].set_ylabel("Comments/Post")
|
249 |
+
axes[0].grid(True)
|
|
|
|
|
250 |
|
251 |
+
axes[1].plot(months, shares_pp, marker="s", color="#ff7f0e")
|
252 |
+
axes[1].set_ylabel("Shares/Post")
|
253 |
+
axes[1].grid(True)
|
254 |
+
|
255 |
+
axes[2].plot(months, clicks_pp, marker="^", color="#2ca02c")
|
256 |
+
axes[2].set_ylabel("Clicks/Post")
|
257 |
+
axes[2].grid(True)
|
258 |
+
|
259 |
+
axes[3].plot(months, comment_share, marker="x", linestyle="--", color="#d62728")
|
260 |
+
axes[3].set_ylabel("Comment Share (%)")
|
261 |
+
axes[3].set_xlabel("Month")
|
262 |
+
axes[3].grid(True)
|
263 |
+
|
264 |
+
plt.xticks(rotation=45)
|
265 |
+
plt.tight_layout(rect=[0, 0, 1, 0.96]) # Leave space for suptitle
|
266 |
+
return fig
|
267 |
|
268 |
|
269 |
def fetch_and_render_analytics(client_id, token):
|