You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, for every one of the 20 teams on the y-axis, I want to colour them according to a Pandas dataframe column which contains a total value for every team. I was wondering if the colourmap could be customised to colour the plots according to a third data variable - either a Pandas Series, numpy array, or something similar.
So for my dataframe the Total would look like this:
Team Total
Angers 356
Monaco 452
PSG 501
Lyon 369
Here's what works as expected:
fig, axes = joypy.joyplot(df, by="Team", column="Minute", figsize =(10,16), x_range = [0,94], linewidth = 1,
legend=False, colormap = color , title= "When do teams in Ligue 1 take their shots?")
Here are a few solutions I tried and failed at. Firstly, I created a colormap for the entire series depending on the Total data using this -
norm = plt.Normalize(group_df["Total"].min(), group_df["Total"].max())
cmap = plt.cm.viridis
sm = matplotlib.cm.ScalarMappable(cmap=cmap, norm=norm)
ar = np.array(group_df["Total"])
Cm = cmap(norm(ar))
sm.set_array([])
1 - Passing the customised colourmap in the function
fig, axes = joypy.joyplot(df, by="Team", column="Minute", figsize =(10,16), x_range = [0,94], linewidth = 1,
legend=False, colormap = Cm , title= "When do teams in Ligue 1 take their shots?")
2 - Passing the array of RGBA tuples to the colour
color = np.array(tuple(map(tuple,Cm)))
fig, axes = joypy.joyplot(df, by="Team", column="Minute", figsize =(10,16), x_range = [0,94], linewidth = 1,
legend=False, color = color , title= "When do teams in Ligue 1 take their shots?")
3 - Using the axes handles to set_facecolor - I saw this here
for col, ax in zip(Cm, axes):
ax.patch.set_facecolor(col)
1 and 2 threw up an invalid RGBA argument and Assertion Error respectively. 3 had no error but the change was not reflected in the resulting plot. All I could gather is that currently, there's a no way to pass a list of colors (with a size similar to the grouped y-axis) or a customised colormap. If that's true, does there exist a work-around which I could implement? Or could a new feature be added?
The text was updated successfully, but these errors were encountered:
I created this joyplot below
However, for every one of the 20 teams on the y-axis, I want to colour them according to a Pandas dataframe column which contains a
total
value for every team. I was wondering if the colourmap could be customised to colour the plots according to a third data variable - either a Pandas Series, numpy array, or something similar.So for my dataframe the
Total
would look like this:Here's what works as expected:
Here are a few solutions I tried and failed at. Firstly, I created a colormap for the entire series depending on the
Total
data using this -1 - Passing the customised colourmap in the function
2 - Passing the array of RGBA tuples to the colour
3 - Using the axes handles to set_facecolor - I saw this here
1 and 2 threw up an
invalid RGBA argument
andAssertion Error
respectively. 3 had no error but the change was not reflected in the resulting plot. All I could gather is that currently, there's a no way to pass a list of colors (with a size similar to the grouped y-axis) or a customised colormap. If that's true, does there exist a work-around which I could implement? Or could a new feature be added?The text was updated successfully, but these errors were encountered: