How to switch the colors of two categories in seaborn?
<p>Let's say I use the following 'iris' example with scatterplots</p>

<pre><code>import pandas as pd
import seaborn as sns
sns.set(style="whitegrid", palette="muted")

# Load the example iris dataset
iris = sns.load_dataset("iris")

# "Melt" the dataset to "long-form" or "tidy" representation
iris = pd.melt(iris, "species", var_name="measurement")

# Draw a categorical scatterplot to show each observation
sns.swarmplot(x="measurement", y="value", hue="species", data=iris)
</code></pre>

<p>which outputs the following plot: </p>

<p><a href="https://i.stack.imgur.com/THix3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/THix3.png" alt="enter image description here"></a></p>

<p>But let's say I wanted to switch the colors between setosa and versicolor, making setosa green and versicolor blue, explicitly using the seaborn palette. I would try something like this:</p>

<pre><code>sns.set(style="whitegrid", palette="muted")
iris = sns.load_dataset("iris")
iris = pd.melt(iris, "species", var_name="measurement")
sns.swarmplot(x="measurement", y="value", hue="species", data=iris, palette=dict(setosa = 'g', versicolor = 'b', virginica = 'r'))
</code></pre>

<p>Naturally, this doesn't work:</p>

<p><a href="https://i.stack.imgur.com/nqk19.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nqk19.png" alt="enter image description here"></a></p>

<p>The color palette is now off. </p>

<p>(1) How do you switch two categories keeping seaborn's colour palette? </p>

<p>(2) What is you wanted to chose another seaborn "standard" color, like cyan? How could I switch setosa from blue to cyan? </p>