I wanted to create a visualisation like this below -
I have succeeded in implementing the code from this answer to get this image below
As can be seen from comparing both images, the difference in colours is great even though the mappable is the same series. Do I need to create my own colourmap for the colours to be more pronounced? My second issue is how do I plot a colorbar for the entire figure?
My code looks like this:
fig, ax = plt.subplots()
##Sonars plotting function -
def plot_inset(width, axis_main, data, x,y):
ax_sub= inset_axes(axis_main, width=width, height=width, loc=10,
bbox_to_anchor=(x,y),
bbox_transform=axis_main.transData,
borderpad=0.0, axes_class=get_projection_class("polar"))
theta = data["Bin_Mids"]
radii = data["Frequency"]
length = data["pass.length"]
colors = plt.cm.magma(length/100)
bars = ax_sub.bar(theta, radii, width=0.3, bottom=0.0, color = colors, alpha=0.5)
ax_sub.set_xticklabels([])
ax_sub.set_yticks([])
ax_sub.yaxis.grid(False)
ax_sub.xaxis.grid(False)
ax_sub.spines['polar'].set_visible(False)
##Calling the function
for player, loc in player_dict.items():
plot_inset(1.1,ax, data = Passer(player), x = loc[0], y = loc[1])
ax.text(loc[0]+10, loc[1], player, size = 6.25, rotation = -90)
player_dict
looks like this (sample):
player_dict = {'Sarah Bouhaddi': [0, 45], 'Marion Torrent': [42, 15], 'Gaëtane Thiney': [97, 68]} ##the list for every player is their x,y co-ordinate
The data
I'm sending to the plotting function for every player is a dataframe and looks like this (a sample) -
Bin_Mids pass.length Frequency
0 1.3660 27.202942 1
1 1.0925 23.024565 3
2 0.8195 16.834414 3
3 0.5465 14.008925 1
4 -0.2735 21.906391 1
5 -0.5465 19.285486 1
6 -0.8195 20.975364 4
7 -1.0925 23.735166 3
Secondary Issue
Another problem I'm facing is to prevent the polar sonars from hiding the pitch lines. I tried setting a zorder but that didn't work. Is there a way to make the frame of the sonars invisible?
Any help would be appreciated. I'm not sure if the issues in this question all deserve questions of their own so I clubbed them all together as they're related.