Reputation: 5137
I am following some examples from the book Python for Data Analysis, and came across an interesting problem. I was wondering if there is a way to "reverse" of a colormap, for example from a blue extreme to a pink extreme to the opposite (pink to blue) for the 'cool' color map.
In the example below, I chart baby names using the 'cool' color map, that shows girls in blue color and boy in pink color. Is there a way to 'reverse' the mapping?
Upvotes: 2
Views: 1802
Reputation: 310267
It's not well documented in the link you showed, but each colormap has a corresponding reversed colormap that you can access by appending an "_r"
to the colormap name. In your case, the colormap name would be "cool_r"
.
This fact is hinted at in the code samples (look for the .endswith("_r")
portions of the code), but it isn't really stated very succinctly.
Upvotes: 3