plotting box plot with seaborn with multidimensional data
<p>I am trying to create a box plot with seaboard as follows:</p>

<p>I have some synthetic data where I have 24 different categories which are generated as:</p>

<pre><code>import numpy as np
x = np.arange(10, 130, step=5)
</code></pre>

<p>Now, for each of these categories I generate 5 random observations as follows:</p>

<pre><code>y = np.zeros(shape=(len(y), 5)) # Each row contains 5 observations for a category
</code></pre>

<p>Now, what I want to do is do a box plot with seaboard where I plot these 5 values along the y-axes (highlighting the confidence interval) and on the x-axes, I would like each of these categories. So, I do:</p>

<pre><code>import seaborn as sis
fig = sns.boxplot(x=x, y=y)
fig.plt.show()
</code></pre>

<p>However, this comes with the exception that the data must be 1-dimensional. I am not sure how to structure my data so that I can plot it.</p>

<p>The problem, as you point out, is the shape of your input data. Without trying to make too many assumptions as to what you are trying to do, I think you are looking for something like</p>

<pre><code>x = np.arange(10, 130, step=5)
y = 4 * np.random.randn(x.size, 5) + 3

x_for_boxplot = np.repeat(x, 5)
y_for_boxplot = y.flatten()

ax = sns.boxplot(x_for_boxplot, y_for_boxplot)
</code></pre>

<p>where <code>x_for_boxplot</code> and <code>y_for_boxplot</code> have been restructured so that they are 1D arrays of the same size which is what <code>sns.boxplot</code> is looking for. I also changed <code>y</code> so that it is made up of random normal values rather than zeros.</p>

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

python matplotlib plot seaborn