Issue
I'm doing a web analytics data trying to examine the impact of emails on our traffic. The code I have for plotting is simple:
for cid in cids:
vdf = df.query('cid_short == @cid')
plt.plot(vdf['counter'],vdf['visits'], color='red', alpha=0.05)
The goal with the format is the transparency will highlight volume. The darker the region, the greater the volume in that area.
However, when I graph the plots, I see that each line is connected by the previous line, which creates weird shapes as seen in the image below.
How can I distinguish each plot programmatically (I'm dealing with 1000s of campaigns - labelled as cids).
Solution
To solve this, I identified that if there are multiple counter instances and are not grouped, then it will show the weird graph. This is important as the line chart is created based on the order of data I feed into it.
To solve this, I did the following:
for cid in cids:
vdf = df.query('cid_short == @cid').groupby(['cid_short','counter'])['visits'].sum().reset_index()
plt.plot(vdf['counter'],vdf['visits'], color='red', alpha=0.05)
Answered By - Adib
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.