October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Use Depthshade in Matplotlib 3D Scatter Plots

Set depthshade=False on each Matplotlib 3D scatter collection to prevent depth-based shading from changing marker opacity and apparent color.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep markers from being lightened or made more transparent according to their depth, pass depthshade=False to each Matplotlib 3D scatter call that needs consistent colors. The option is enabled by default in the current stable API.

Disable depth shading for consistent marker colors

depthshade is an option on Axes3D.scatter. It controls whether Matplotlib shades markers to give the appearance of depth. Set it to False when that visual effect interferes with comparing colors.

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.scatter(x, y, z, c="royalblue", depthshade=False)
plt.show()

This disables depth shading for that scatter collection; it does not change the supplied color itself. The official Axes3D.scatter API documents the default as True, following rcParams["axes3d.depthshade"].

Apply the setting to every scatter collection

Each call to scatter creates a collection with its own depth-shading choice. Set the argument on every group that should use consistent colors:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.scatter(x1, y1, z1, c="royalblue", label="Group A", depthshade=False)
ax.scatter(x2, y2, z2, c="darkorange", label="Group B", depthshade=False)

Disabling it on one collection does not configure another collection.

What depth shading changes

With depth shading enabled, Matplotlib adjusts marker alpha according to projected point depths and sorts the colors to match depth ordering. As a result, markers using the same base color can look lighter or more transparent at different depths. The implementation is visible in the Matplotlib 3D axes source.

Keep shading but control its minimum opacity

If the depth cue is useful but distant points look too transparent, Matplotlib 3.11 and later provide depthshade_minalpha, which sets the minimum alpha used by shading. Its documented default is 0.3; the value can also be inherited from rcParams["axes3d.depthshade_minalpha"]. See the current scatter API reference for the version-specific parameter details. Choose depthshade=False instead if you want to remove the effect rather than adjust its opacity floor.

Check the color input if markers still differ

Turning off depth shading does not make different color inputs identical. The c argument can be a single color, a sequence of colors, RGB or RGBA rows, or values mapped through a colormap and normalization. If markers remain differently colored, inspect c and any cmap or norm arguments in the API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version notes

The current stable reference is labeled Matplotlib 3.11.2: it supports depthshade=None to use the configured rcParams value and documents depthshade_minalpha as added in 3.11. Older official documentation, including the Matplotlib 3.2.0 reference, also lists depthshade with a default of True. Check the documentation for your installed version for exact defaults and available parameters.

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 *

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.