Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Call ax.plot() once for each data series on the same Axes. Matplotlib assigns successive colors automatically; use color= when you need a specific palette, and add labels plus a legend to identify the lines.
Plot multiple lines with automatic colors
When you omit a color, Matplotlib takes each line’s color from the Axes property cycle. This is the simplest option when the exact colors do not matter.
As an Amazon Associate I earn from qualifying purchases.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(x, y1, label="Series 1")
ax.plot(x, y2, label="Series 2")
ax.legend()
plt.show()
Replace x, y1, and y2 with your data. Both calls draw on the same Axes, so the lines appear together. The labels are shown in the legend. Matplotlib cycles through the configured styles; if you plot more lines than there are entries in the cycle, styles repeat. See the pyplot.plot API reference.
Choose exact colors for each line
Pass a color to each call when a series needs a specific color or the same series should retain its color across plots.
#1 Best Overall
ax.plot(x, y1, color="tab:blue", label="Series 1")
ax.plot(x, y2, color="#ff7f0e", label="Series 2")
Matplotlib accepts short color codes such as 'r', names such as 'green', hexadecimal strings such as '#008000', the 'tab:' Tableau color family, and cycle-index strings such as 'C0' and 'C1'. A Cn value refers to an entry in the default property cycle. The colors guide describes supported color specifications.
Set a palette for one chart or future charts
Use a custom cycle on one Axes
Set the property cycle before plotting to make its colors apply successively to lines on that Axes.
Rank #2
from cycler import cycler
fig, ax = plt.subplots()
ax.set_prop_cycle(color=["#4c78a8", "#f58518", "#54a24b"])
ax.plot(x, y1, label="Series 1")
ax.plot(x, y2, label="Series 2")
ax.legend()
This keeps the palette local to that chart. The Axes styling guide explains property cycles.
Set the default cycle for subsequently created Axes
To configure a palette for Axes created afterward, set axes.prop_cycle through Matplotlib’s runtime configuration:
import matplotlib as mpl
from cycler import cycler
mpl.rcParams["axes.prop_cycle"] = cycler(color=["#4c78a8", "#f58518", "#54a24b"])
This affects subsequently created Axes, not Axes that already exist. For the available configuration setting, see the customization guide and the configuration API reference. Changing lines.color is not the way to set the usual color cycle for plot(); use axes.prop_cycle.
Plot several datasets in one call
Repeated calls are often clearest when each series needs its own label or color. The plot() API also accepts multiple [x], y, [fmt] groups in a single call, or 2D arrays where each column represents a dataset. With 2D x and y, their shapes must match. If only one argument is 2D, the other one-dimensional sequence is reused for each dataset. Additional keyword arguments in a grouped call apply to all datasets, so repeated calls offer more direct per-series control. Consult the API reference for the accepted forms.
Rank #4
Make overlapping lines easier to distinguish
A legend identifies named series, while markers and line styles provide visual cues in addition to color. You can set them on each line, for example with marker="o" or linestyle="--". Color alone does not guarantee that a chart will be accessible or readable in every viewing condition; use multiple cues when lines overlap or the figure has many series.
Check the Matplotlib version
The stable documentation identifies its current API page as Matplotlib 3.11.2, but the stable URL can change as releases advance. If your code is pinned to a particular Matplotlib version, check that version’s documentation for behavior and supported options.
Quick Recap
Best Value
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.




