seaborn boxplots at desired distances along the x axis

import numpy as np
import pandas as pd
import seaborn as sns
df = pd.DataFrame(dict(x=np.repeat([0, 3, 5, 6], 10),
                       y=np.random.randn(40)))
sns.boxplot(x="x", y="y", data=df, order=np.arange(7))

enter image description here


UPDATE: It seems, I was wrong, as mwaskom pointed out, you can specify positions by cleverly using order keyword, but it seems you would need to reshape your data from 'wide' to 'long' format.


The short answer is no, seaborn.boxplot does not have an option to specify the position of the boxplots along the x axis.

If you don't care much for the style or can specify it manually, you can use pandas.DataFrame.boxplot instead, which has positions property.

import matplotlib.pyplot as plt
import pandas as pd
import numpy.random as rnd   # just to generate some data

data = pd.DataFrame(rnd.randn(10,4))
data.boxplot(positions=[1,5,6,10])
plt.grid('off')

boxplot with positions