I want to plot a swarmplot like this
I can highlight the specific point. But I want all the points get kind of the colormap. And the specific point has the respectively color. I'm trying hue and palette but it does not work.
palette = sns.light_palette("purple", reverse=False, n_colors=df[typeId].max())
ax = sns.swarmplot(x = df[typeId], ax = ax, hue = df[typeId], alpha = 0.8, size = 8)
axData = ax.get_children()
for a in axData:
if type(a) is matplotlib.collections.PathCollection:
offsets = a.get_offsets()
break
ax.scatter(offsets[index,0], offsets[index,1], marker='o', color='red', zorder=10, s=200, edgecolor = "white")
ax.text(offsets[index,0], offsets[index,1]-0.1,"Value: " + str(player[typeId]) + "\nPercentile rank: " + str("{0:.2f}".format(player[typeRank]*100)), ha = "center", color = "white", zorder = 9, fontproperties=prop_bold,fontsize=10)
It seems that when no
y=
is given,swarmplot()
doesn't take thehue=
parameter into account. (And wheny
is a constant, the code seems to hang.)A workaround is to set the color manually: