I have an array of 100 float values in the range [0, 1]. (min and max values are not necessarily 0 and 1)
I want to map them to a hue in the "icefire" color palette, in a swarmplot. In other words I want the data points, the dots, to have a hue based on the 100-val-array.
Now, I do not want the lowest value to map to the "lowest" color in the palette; I want the lowest value to map to the "corresponding" color in the palette.
Let's imagine the color palette just goes from [0, 1] as well, so in the case of "icefire", 0 is light blue and 1 is light red (icefire goes from light blue, to black in the middle, to light red).
With that in mind, if the minimum value in the 100-val-array is 0.27, then I want that value to map to the color 0.27, i.e., in the case of icefire, somewhere in the blues.
I hope I am making myself clear.
I have no idea how the "palette" parameter in swarmplot works, but it is not doing what I want.
The reason I need this is because the color of the data point is important, as it reflects the actual value in the 100-val-array.
I believe by just using swarmplot(..., palette="icefire"), that is not what happens.
Unlike a scatter plot, Seaborn's
swarmplot
(currently?) doesn't use avmin=
andvmax=
parameter. Theswarmplot
considers the hue mapping as categorical. You can simulate working with a colormap by creating apalette
as a dictionary that maps every possiblehue
value to its corresponding color.Here is how your example could look like: