I am attempting to make a swarmplot for my data where the the top 20 most frequent times appear on the y-axis, and each count value for each time is plotted. For some reason, when I plot just the times, the graph is shaped perfectly, but does not contain a y-axis for the counts/frequencies.
When I include the count column for the y-axis argument, I get an incorrect plot, where the counts are plotted horizontally.
# Top 20 most frequent times to tweet
tweetsDF[‘Time’] = tweetsDF.timestamp.map(lambda timestamp: timestamp[timestamp.index(‘:’)-2:timestamp.index(‘:’)+7].strip())
tweetsDF[‘TimeCount’] = tweetsDF.groupby(‘time’)[‘time’].transform(‘count’)
TimeData = tweetsDF[[‘Time’, ‘TimeCount’]]
counts = Counter(TimeData.Time).most_common(20)
counts = [val[0] for val in counts]
Top20Times = TimeData[TimeData[‘Time’].isin(counts)
As described earlier, I tried plotting with the y-axis argument, yet I do not get my desired output
sns.catplot(kind=’swarm’, x=’Time’,data=Top20Times), plt.xticks(rotation=90):
output:
:
(This is my desired plot, however, I am unable to get the y-axis count values for each time)
Where as, if I include the y-axis argument, I do not get my desired graph:
sns.catplot(kind=’swarm’, x=’Time’, y=’TimeCount’,data=Top20Times), plt.xticks(rotation=90)
output: