Plotting DataFrame with column in all subplots
<p>Consider that I have a pandas DataFrame with 3 columns. I would to plot two of these columns as separate subplots and the other one should appear on both the other subplots.</p>

<p>To explain better, consider the example</p>

<pre><code>x = np.linspace(0,10,5)
y1 = 2*x
y2 = 3*x
y3 = 4*x

df = pd.DataFrame(index=x, data=zip(*[y1,y2,y3]))
df.plot(subplots=True, layout=(1,3), ylim=[0,40])
</code></pre>

<p>This code displays
<a href="https://i.stack.imgur.com/oOWc3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oOWc3.png" alt="enter image description here"></a></p>

<p>Which is close to what I want. But not exactly. I would like that plot to have only two subplots. One with columns 0 and 1, and the other with columns 0 and 2. As is comparing each column to another column. The closest I got was</p>

<pre><code>df[[1,2]].plot(subplots=True, layout=(1,2), ylim=[0,40])
plt.plot(df.index, df[0], label=0)
</code></pre>

<p>which gives me this picture, where column 0 only appears in the second subplot, and not on all of them:</p>

<p><a href="https://i.stack.imgur.com/bFN2H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bFN2H.png" alt="enter image description here"></a></p>

<p>Is there any way to do this? Preferably not going completely outside of pandas. I know I could just iterate through columns 1 and 2 and manually plot them with pyplot alongside column 0, but that's just too much code and I'd like to avoid that, if possible.</p>