andrewRowlinson / mplsoccer

Football pitch plotting library for matplotlib
MIT License
391 stars 80 forks source link

Shared color scale when plotting multiple pitches in a grid? #91

Closed kirstenncrane closed 1 year ago

kirstenncrane commented 1 year ago

Hi,

I am plotting three pitches side by side using pitch.grid() and creating a heatmap on each one with something like pitch.heatmap(bin_stat_i, axs[i], cmap='Reds', edgecolors='#f9f9f9'), and the pitch.label_heatmap() function as well.

The numeric labels are comparable across pitches, but the colors are not, they each use their own scale based on the min and max of the individual heatmap. Is there a way for the three to use the same colour scale?

Thank you for any help!

andrewRowlinson commented 1 year ago

Yup, that's possible. Use vmin and vmax arguments when using the heatmap method. You could use the minimum and maximum from all of the heatmaps to decide these levels. I think something like bs['statistic].max() might work for finding it for one heatmap.

kirstenncrane commented 1 year ago

Perfect, thanks @andrewRowlinson !