Plot Multiple Columns from a Pandas DataFrame (Shared Axes, Subplots, Dual Axis)
Quick answer
Pass a LIST of columns to the y argument of DataFrame.plot(): df.plot(y=['col1','col2']) draws one line per column against the index. Set a single x column for a shared x-axis (df.plot(x='date', y=['col1','col2'])). x takes ONE column, not a list. Use subplots=True for separate panels, and secondary_y=['col2'] to put a column on a second y-axis. Call plt.show() to render.
Short answer: Pass a list to y — df.plot(y=['col1','col2']) draws one line per column. x takes a single column (the shared x-axis), not a list. Use subplots=True for separate panels and secondary_y= for a dual axis. Then plt.show().
Several columns on shared axes
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("data.csv")
df.plot(y=["col1", "col2", "col3"], kind="line") # x defaults to the index
plt.show()To use a specific column as the x-axis, pass one column to x:
df.plot(x="date", y=["revenue", "profit"], kind="line")
plt.show()x is a single shared axis — passing a list to x is invalid; the multiple series belong in y.
Separate panels with subplots=True
When columns have very different scales, give each its own panel:
df.plot(subplots=True, layout=(2, 2), figsize=(10, 6), sharex=True)
plt.tight_layout()
plt.show()Two scales on one chart: secondary_y
df.plot(y=["price", "volume"], secondary_y=["volume"])
plt.show()volume is plotted against a right-hand y-axis so a large-scale series doesn't flatten a small one.
One column, or all of them
df["col1"].plot() # a single column
df.plot() # every column, against the indexCommon traps
- Passing a list to
x—xis one column; the series go iny. - Forgetting
plt.show()— outside notebooks, nothing renders without it. - Mismatched scales on shared axes — use
subplots=Trueorsecondary_y.
Related guides
Key takeaways
- •Pass a LIST to y: df.plot(y=['a','b']) — one series per column.
- •x takes a SINGLE column (the shared x-axis), not a list; omit it to use the index.
- •subplots=True draws each column in its own panel.
- •secondary_y=['col'] puts a column on a right-hand axis (for different scales).
- •df['col'].plot() plots one column; df.plot() with no args plots them all against the index.
Frequently asked questions
How do I plot multiple columns of a DataFrame at once?
Pass the column names as a list to y: df.plot(y=['col1','col2'], kind='line'). pandas draws one series per column on shared axes. To set the horizontal axis, pass a single column to x, e.g. df.plot(x='date', y=['col1','col2']).
Can I pass a list to the x parameter?
No. x is a single column that becomes the shared horizontal axis. Passing a list to x is invalid — the multiple series go in y. If you omit x, the DataFrame index is used as the x-axis.
How do I put each column in its own subplot?
Use subplots=True: df.plot(subplots=True, layout=(2,2), figsize=(10,6)). Each column is drawn in a separate panel, which is useful when columns have very different scales.
How do I plot two columns with different scales together?
Use a secondary axis: df.plot(y=['price','volume'], secondary_y=['volume']). 'volume' is drawn against a right-hand y-axis so a large-scale column doesn't flatten a small-scale one.
Software Engineering Leader & Technical Author · Updated August 26, 2026