Reputation: 2243
There's a thread on stackoverflow with exactly the same question, but it is for Matlab. However, I'm using matplotlib and I don't know how to proceed. Basically, I have a number of boxplots, but I want to separate them like this (copied shamelessly from the thread above):
How can I go about this? There's a suggestion to put an invisible boxplot in between the two groups, but I don't know how to make the tick (not just the label) vanish only for that value.
Upvotes: 2
Views: 1885
Reputation: 10860
There's a keyword positions
in matplotlib's boxplot
(here put as first parameter for focusing reason):
import matplotlib.pyplot as plt
plt.boxplot(positions=[0, 1, 2, 5, 6], labels=['1\na', '1\nb', '1\nc', '2\na', '2\nb'],
x=[np.random.random_sample(100)-.05, np.random.random_sample(100), np.random.random_sample(100)+.1, np.random.random_sample(100)+.2, np.random.random_sample(100)+.3])
Upvotes: 5