How to rank plot in seaborn boxplot?
<p>Take the following seaborn boxplot for example, from <a href="https://stanford.edu/~mwaskom/software/seaborn/examples/horizontal_boxplot.html" rel="nofollow">https://stanford.edu/~mwaskom/software/seaborn/examples/horizontal_boxplot.html</a></p>

<pre><code>import numpy as np
import seaborn as sns
sns.set(style="ticks", palette="muted", color_codes=True)

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

# Plot the orbital period with horizontal boxes
ax = sns.boxplot(x="distance", y="method", data=planets,
                 whis=np.inf, color="c")

# Add in points to show each observation
sns.stripplot(x="distance", y="method", data=planets,
              jitter=True, size=3, color=".3", linewidth=0)


# Make the quantitative axis logarithmic
ax.set_xscale("log")
sns.despine(trim=True)
</code></pre>

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

<p>Is it possible to "rank" the entries, from greatest to lowest (or vice versa)? In this plot, "astrometry" should be the last entry, if ranking from greatest to lowest.</p>

<p>Try this: </p>

<pre><code>import numpy as np
import seaborn as sns
sns.set(style="ticks", palette="muted", color_codes=True)

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

ranks = planets.groupby("method")["distance"].mean().fillna(0).sort_values()[::-1].index

# Plot the orbital period with horizontal boxes
ax = sns.boxplot(x="distance", y="method", data=planets,
                 whis=np.inf, color="c",  order = ranks)

# Add in points to show each observation
sns.stripplot(x="distance", y="method", data=planets,
              jitter=True, size=3, color=".3", linewidth=0, order = ranks)

# Make the quantitative axis logarithmic
ax.set_xscale("log")
sns.despine(trim=True)
</code></pre>

<p><a href="http://i.stack.imgur.com/FYJlf.png" rel="nofollow"><img src="http://i.stack.imgur.com/FYJlf.png" alt="image"></a></p>

python pandas matplotlib seaborn