DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Zoom In on a 3D Scatter Plot in Matplotlib

Learn when to use Matplotlib’s 3D axis limits, interactive mouse zoom and camera controls to inspect a scatter plot.

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.

For a repeatable close-up, set narrower x, y and z axis limits with set_xlim(), set_ylim() and set_zlim(). To explore a plot by hand, right-click and drag vertically in an interactive backend. If you want to see the data from another direction, change the camera with view_init() instead; that changes the angle, not the data range.

Set a reproducible close-up with axis limits

Axis limits define the data-coordinate ranges visible along each axis. Narrowing them shows a smaller region of the existing plot; it does not change the underlying data values.

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.scatter(xs, ys, zs)

# Replace these bounds with the region you want to inspect.
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_zlim(zmin, zmax)

plt.show()

The official 3D scatter example uses this figure-and-axes setup and calls ax.scatter(xs, ys, zs). Choose limits based on your own data rather than copying example ranges.

Each limit method accepts a lower and upper bound. For example, ax.set_xlim((xmin, xmax)) sets both x bounds; you can also set one bound while leaving the other unchanged. Passing bounds in reverse order reverses that axis’s direction. The same patterns apply to y and z. See the APIs for x limits, y limits and z limits.

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

Zoom interactively with the mouse

In an interactive Matplotlib backend, right-click and drag vertically to zoom the 3D scene. The documented default gestures are left-drag to rotate, middle-drag to pan and right-drag to zoom. These controls belong to mplot3d scene interaction; the 2D toolbar’s pan and zoom buttons are not the controls for manipulating the 3D scene.

Mouse interaction depends on an interactive backend. A static rendered image will not respond to dragging. Matplotlib documents the default mouse-button assignments in the mouse_init API, which also allows the buttons to be configured.

Change the viewing angle, not the zoom range

If points overlap or hide one another, rotate the camera to inspect the scatter plot from another direction. Use ax.view_init(elev=..., azim=..., roll=...), with angles in degrees, or rotate by dragging in an interactive figure. These controls change camera orientation; they do not select a narrower data-coordinate range. The view_init API documents the angle parameters.

The current stable Matplotlib view-angle guide identifies its documentation as version 3.11.2 and describes arcball as the default mouse-rotation style. It notes that before Matplotlib 3.10, mouse position corresponded directly to azimuth and elevation, so rotation behavior can differ in older releases. See the mplot3d view-angle guide.

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

Choose the control that matches your goal

Goal Control What it changes
Show a known subset or range of values set_xlim(), set_ylim(), set_zlim() Visible axis bounds in data coordinates
Explore the scene by hand Right-drag vertically in an interactive backend Interactive zoom of the 3D scene
Reduce overlap or see another side view_init() or mouse rotation Camera orientation
Change apparent axis proportions or projection set_box_aspect() or projection settings Display geometry and projection

Matplotlib renders a 3D scene as a 2D projection. Box aspect and projection choices affect how the axes appear on screen; they are presentation controls, not substitutes for setting the data region you want to inspect. The mplot3d overview describes these capabilities and notes that 3D plotting in Matplotlib is less mature than its 2D plotting.

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

Understand what limits do to plotted objects

Setting axis limits controls the visible range, but clipping behavior for complete 3D objects is a separate concern. In the current axis-limit clipping example, axlim_clip defaults to False. When set to True, a line segment with a vertex outside the view limits is hidden as a whole; the example describes the same behavior for 3D patches. This option is not required for an ordinary close-up of a scatter plot.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.