Load the CSV into a pandas DataFrame, select one column for the x-axis and one or more columns for the y-axis, then plot each y column on the same Matplotlib axes. Check that numeric columns were parsed as numbers and dates as datetimes before plotting; otherwise, the chart may not represent the data as intended.
Load and check the CSV
Use pandas.read_csv() to load the file. The example below assumes the CSV has headers named date, sales, and returns; replace them with the headers in your file.
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("data.csv", parse_dates=["date"])
fig, ax = plt.subplots()
ax.plot(df["date"], df["sales"], label="Sales")
ax.plot(df["date"], df["returns"], label="Returns")
ax.set_xlabel("Date")
ax.set_ylabel("Value")
ax.legend()
fig.tight_layout()
plt.show()
pandas.read_csv documentation covers parser options such as separators, headers, explicit data types, missing values, and date parsing. By default, the function expects comma-separated data and infers headers. If your file uses another delimiter or has no header row, set the appropriate arguments rather than relying on those defaults.
Verify the columns and types
Before plotting, confirm that the column names match the CSV and that the values have the intended types. A numeric-looking column imported as text may be plotted as categories. Matplotlib treats string x values categorically, which can produce a separate tick for every distinct string. Convert values intended as numbers to numeric data before charting.
#1 Best Overall
For dates, parse the date column during CSV loading, as in parse_dates=["date"]. Matplotlib’s date converter supports datetime values and provides date-appropriate axis locators and formatters. See the Matplotlib units guide for details on date and string handling.
Plot multiple series on one set of axes
Each call to ax.plot() adds a line to the same axes. Pass the shared x column first and a y column second, then give each series a descriptive label. Calling ax.legend() displays those labels so readers can tell the lines apart.
Rank #2
Use axis labels that describe the plotted quantities. If the lines represent values with different units or scales, a single y-axis may be misleading; this pattern puts every series on the same axes and does not normalize or rescale their values.
Choose a plotting form that fits the data
Repeated calls for independent styling
The example uses one ax.plot(x, y, label=...) call per series. This is usually the clearest approach when each line needs its own label, marker, color, or line style. Matplotlib also supports line styling through arguments such as color, marker, and linestyle.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
Two-dimensional y data for shared x values
If several y series are arranged as columns in a two-dimensional array and all share the same x coordinates, Matplotlib can plot the columns as separate lines in one call. This is concise for uniformly structured data; repeated calls are easier to read when series need individual labels or styling.
Grouped x/y pairs
plot() also accepts grouped x/y pairs in one call. The available forms are documented in the Matplotlib plot reference. Pick the form that keeps the relationship between each x series and its y series clear.
Rank #4
Use the axes interface for a reusable figure
The example uses Matplotlib’s object-oriented interface: fig, ax = plt.subplots() creates a figure and axes, and plotting and labeling are performed through ax. This makes it straightforward to work with a particular axes, especially as a figure grows more complex. The pyplot overview describes pyplot’s role and recommends the object-oriented interface for complex plots; pyplot remains suitable for simple scripts and interactive use.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




