I have two temporal sequences, let's say tweets per time of the day, for two different categories. I would like to plot them as a joyplot with as x axis the time of the day and as height the number of tweets.
My code is:
from joypy import joyplot
import pandas as pd
import numpy as np
np.random.seed(0)
df = pd.DataFrame(index = range(24 * 2))
df['value'] = list([int(10 * aa) for aa in np.random.rand(24 * 2)])
df.loc[23 : 30, 'value'] = 0
df['hour'] = [aa for aa in range(24)] * 2
df['cat'] = ['A'] * 24 + ['B'] * 24
joyplot(df, by = 'cat', column = 'hour')
so df.head(3)
will return:
value hour cat
0 5 0 A
1 7 1 A
2 6 2 A
I am expecting to see the variations of value
in hour
but I do get two flat plots
Plotting the two lines (to have an idea of the expected plot)
dfa = df[df.cat == 'A']
dfb = df[df.cat == 'B']
plt.figure()
plt.plot(dfa.hour, dfa.value)
plt.plot(dfb.hour, dfb.value)
How should I fix this?