Plot each column of Pandas dataframe pairwise against one column
<p>I have a pandas dataframe where one of the columns is a set of labels that I would like to plot each of the other columns against in subplots. In other words, I want the y-axis of each subplot to use the same column, called 'labels', and I want a subplot for each of the remaining columns with the data from each column on the x-axis. I expected the following code snippet to achieve this, but I don't understand why this results in a single nonsensical plot:</p>

<pre><code>examples.plot(subplots=True, layout=(-1, 3), figsize=(20, 20), y='labels', sharey=False)
</code></pre>

<p>The problem with that code is that you didn't specify an x value. It seems nonsensical because it's plotting the <code>labels</code> column against an index from 0 to the number of rows. As far as I know, you can't do what you want in pandas directly. You might want to check out <a href="https://seaborn.github.io/generated/seaborn.PairGrid.html#seaborn.PairGrid" rel="nofollow">seaborn</a> though, it's another visualization library that has some nice grid plotting helpers.</p>

<p>Here's an example with your data:</p>

<pre><code>import pandas as pd
import seaborn as sns
import numpy as np

examples = pd.DataFrame(np.random.rand(10,4), columns=['a', 'b', 'c', 'labels'])
g = sns.PairGrid(examples, x_vars=['a', 'b', 'c'], y_vars='labels')    
g = g.map(plt.plot)
</code></pre>

<p>This creates the following plot:
<a href="https://i.stack.imgur.com/cv8n8.png" rel="nofollow"><img src="https://i.stack.imgur.com/cv8n8.png" alt="enter image description here"></a></p>

<p>Obviously it doesn't look great with random data, but hopefully with your data it will look better. </p>

python pandas plot