Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Matplotlib turns Python data into charts, from a quick line plot to carefully arranged figures for reports and applications. Start with plt.subplots(), draw through its Axes, and add labels; as plots grow, the Figure-and-Axes model makes code easier to organize and reuse.

Install Matplotlib and make your first plot

Install Matplotlib in the environment where you run Python. For pip, use:

python -m pip install -U matplotlib

The official getting-started guide also documents installation with conda, pixi, and uv. Consult the installation guide for current package-manager instructions and compatibility details.

This complete example plots a small set of numeric values:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import matplotlib.pyplot as plt

x = [0, 1, 2, 3]
y = [0, 1, 4, 9]

fig, ax = plt.subplots()
ax.plot(x, y, label="y = x squared")
ax.set_title("A simple line plot")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.legend()

plt.show()

plt.subplots() creates a Figure and an Axes. ax.plot() draws the data, and the label, title, axis labels, and legend make the chart interpretable. plt.show() requests display; whether a window appears depends on the Python environment and its Matplotlib backend.

Understand Figure, Axes, Axis, and Artist

Matplotlib’s object model gives each part of a figure a distinct role. The names are similar, but an Axes is not the same thing as an Axis.

  • Figure: the overall canvas or container. A Figure can hold one or more Axes.
  • Axes: the plotting area where data is drawn and plot elements are configured. A chart usually has an x-axis and y-axis within its Axes.
  • Axis: an object that controls a dimension’s scale and ticks, including their placement and labels.
  • Artist: the general term for visible elements in a figure, such as lines, text, and patches.

In the example, fig refers to the Figure and ax to its Axes. The plotting method creates visible Artists, while methods such as set_xlabel() configure text associated with the plot. This structure is explained in the Matplotlib quick-start guide.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Choose the interface that fits the task

Matplotlib offers a convenient state-based interface through pyplot and an explicit interface that works directly with Figure and Axes objects. The choice affects how clearly plotting code communicates which chart it changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach Explicitness Quick exploration Reusable or multi-panel code Passing plotting logic to helper functions
pyplot state-based calls Implicit: calls act on the current figure or Axes. Convenient for short interactive work. Can become harder to track as figures grow. Less direct, because the target plot depends on current state.
Explicit Figure/Axes methods Explicit: code names the object being changed. Works, though it requires keeping the objects. Well suited to complex plots, scripts, and multiple Axes. Convenient: pass an Axes into a function.

For example, a helper function can draw on whichever Axes it receives:

def add_series(ax, x, y, label):
    ax.plot(x, y, label=label)

fig, ax = plt.subplots()
add_series(ax, [0, 1, 2], [0, 1, 4], "observations")
ax.legend()
plt.show()

This avoids relying on an implicit “current” plot, which is especially useful when a script creates several charts or panels. A pyplot-only version is still handy for a quick experiment:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
plt.plot([0, 1, 2], [0, 1, 4])
plt.title("Quick check")
plt.show()

Prefer the explicit style as plotting logic becomes reusable or more involved. Avoid old examples built around pylab; the current quick-start documentation describes that approach as strongly deprecated.

Make charts clear and readable

A chart should make its data and comparisons easy to understand. Add descriptive titles and axis labels, use a legend when multiple series need identification, and choose scales and ticks that suit the values rather than accepting defaults without inspection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Labels and titles: name the quantities and units where applicable. A title can state what the plot shows; labels explain each dimension.
  • Legends: assign meaningful labels to plotted series and call ax.legend() when readers need to distinguish them.
  • Scales and ticks: use a scale that matches the data and make tick positions and labels readable. The Axis objects manage scales and ticks.
  • Color and annotation: use color deliberately to distinguish series or encode values, and add annotations when a particular point or region needs explanation.
  • Categorical values: strings can be interpreted as categorical positions. A long sequence of unique strings may produce an excessive number of ticks; use categories only when they are meaningful and manageable.
  • Multiple views: place related plots on separate Axes when the comparison benefits from distinct scales or chart types.

For two related panels, create multiple Axes with plt.subplots() and label each one directly:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
fig, (ax1, ax2) = plt.subplots(1, 2)

ax1.plot([0, 1, 2], [0, 1, 4])
ax1.set_title("Series A")
ax1.set_xlabel("x")
ax1.set_ylabel("value")

ax2.plot([0, 1, 2], [0, 2, 3])
ax2.set_title("Series B")
ax2.set_xlabel("x")

plt.show()

Each Axes can be configured independently while both belong to the same Figure. For more layout approaches, see the quick-start guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Display a plot or save it to a file

Showing a chart and writing one to disk are different tasks. Interactive display requires a suitable GUI backend and environment; file output can use non-interactive backends such as Agg, ps, pdf, or svg. Availability depends on the system and installed bindings or optional packages.

Goal Typical Matplotlib operation What to check
Display a plot interactively plt.show() The configured backend and environment must support display. GUI frameworks may require additional system bindings or packages.
Save a plot fig.savefig("chart.png") savefig can write image or vector output; use a suitable filename extension and check format-specific requirements.

For example, save the Figure before or after requesting display:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
fig, ax = plt.subplots()
ax.plot([0, 1, 2], [0, 1, 4])
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.savefig("chart.png")

If plt.show() does not open a window, check the official installation and troubleshooting guidance for backend requirements in your environment. LaTeX rendering and animation workflows can also require optional dependencies, so consult the relevant documentation before relying on them.

Move from basics to advanced Matplotlib

Once the Figure-and-Axes workflow is comfortable, explore features according to the problem you need to solve. The official tutorials cover these topics in greater depth.

  • Styles and rcParams: apply consistent visual defaults across plots or configure individual settings.
  • Layout: control how multiple Axes, labels, and legends fit within a Figure.
  • Legends: customize placement and presentation when basic legends are not enough.
  • Animation: update plotted elements over time; confirm the required output workflow and dependencies for your target environment.
  • Transforms and paths: position elements using coordinate systems or build more specialized graphical shapes.
  • Rendering performance: techniques such as blitting can help optimize certain animation workflows, but are not prerequisites for ordinary plotting.

Matplotlib supports static, animated, and interactive visualizations. The official documentation is the best place to check current APIs and environment-specific requirements as your needs expand.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.