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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Change the marker size in a Matplotlib 3D scatter plot with the s argument on Axes3D.scatter:

ax.scatter(x, y, z, s=40)

The value is measured in typographic points squared, not pixels and not units from your x, y, or z data. A scalar gives every point the same size; an array-like value lets each point have its own size. The documented default is s=20 in the Matplotlib 3.11.2 API.

The smallest edit to an existing 3D scatter plot

If your plot already has a three-dimensional axes object named ax, add s directly to the scatter call:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.scatter(x, y, z, s=40)

Replace 40 with the size you want. The argument belongs to the scatter call, not to plot_surface, plot, or the figure itself. The Matplotlib Axes3D.scatter API reference defines s as a float or array-like marker size and gives it a default of 20.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • 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.

For example, this changes a call that previously used the default:

# Before: uses the API default, s=20
ax.scatter(x, y, z)

# After: every marker uses the supplied size
ax.scatter(x, y, z, s=40)

When you redraw the figure, the new collection uses the requested size. If the plot is built inside a loop, put s on the call in that loop so every newly created collection receives the intended value.

Complete setup for a new 3D scatter plot

A 3D scatter plot needs an axes object configured with the 3D projection. The official Matplotlib 3D scatter gallery example uses fig.add_subplot(projection='3d') and passes x, y, and z coordinates to scatter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import matplotlib.pyplot as plt

# Example coordinate data
x = [1, 2, 3, 4, 5]
y = [2, 1, 4, 3, 5]
z = [0, 3, 1, 4, 2]

fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.scatter(x, y, z, s=40)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
plt.show()

The important parts are the 3D projection when the axes is created and the three coordinate sequences in ax.scatter(x, y, z, ...). The labels are optional and do not affect marker size.

What the s value actually means

Matplotlib documents marker size as “points2.” A point is a typographic unit, so s=40 does not mean a 40-pixel diameter, a 40-pixel radius, or a 40-unit square in your data coordinate system. It is an area-like display value used by the marker collection.

This distinction matters when you compare plots. A marker with s=40 may occupy a different number of screen pixels when you change the figure size, display resolution, export dimensions, or viewing context. The API defines the unit but does not prescribe one universally ideal value for every figure. Treat example values as starting points and adjust them while looking at the final output.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 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.

With no s argument, the documented default is 20 for the Matplotlib 3.11.2 Axes3D.scatter signature. Supplying a value replaces that default for the call.

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.

Choose one size for all points or a size for each point

Goal Value passed to s Example Requirement
Uniform markers One scalar number s=40 Every plotted point receives the same display size.
Variable markers An array-like of numbers s=[10, 20, 40, 80, 120] Provide one size for each plotted point, in the same order as the coordinate data.
Default behavior Omit s ax.scatter(x, y, z) Uses the API default of 20 for the cited Matplotlib version.

Uniform marker size with a scalar

Use a scalar when marker area is only a visual choice and has no meaning in the data:

ax.scatter(x, y, z, s=15)

All points use the same size, including points that overlap in the projected view. A scalar is also the simplest option when you want to tune readability by changing one number.

Point-by-point sizes with an array-like

Pass a list, tuple, or NumPy array when marker size should vary:

sizes = [12, 24, 36, 60, 90]
ax.scatter(x, y, z, s=sizes)

The first size belongs to the first x, y, and z coordinates, the second size to the second coordinates, and so on. Keep the size sequence aligned with the data after filtering, sorting, or otherwise rearranging points.

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

With NumPy, the same pattern can be expressed as an array:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • 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.
import numpy as np

sizes = np.array([12, 24, 36, 60, 90])
ax.scatter(x, y, z, s=sizes)

The API describes s as array-like, so it is not limited to a particular container type. The practical rule is that the array must provide a corresponding value for every point being plotted.

Deriving sizes from another measurement

If another variable controls visual prominence, transform it into positive display values before passing it to s. For example:

importance = np.array([0.2, 0.5, 0.8, 1.1, 1.6])
sizes = 20 + importance * 40
ax.scatter(x, y, z, s=sizes)

The multiplication and offset in this example are design choices, not a Matplotlib calibration. They simply keep the values away from zero while preserving the ordering of the importance values. Inspect the result and adjust the transformation for your figure.

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

Practical size values and visual tuning

There is no documented “best” value that looks correct for every 3D chart. Start with a scalar such as 20, 40, or 80, then check the actual figure at the size in which readers will see it. A value that is legible in an interactive window can look crowded after a camera angle change or when many points project onto the same region.

  • Use a smaller value when dense points obscure one another.
  • Use a larger value when a sparse plot is difficult to see or when the figure will be displayed at a small physical size.
  • When sizes encode a variable, preserve the ordering of values and avoid a range so wide that small points disappear.
  • Remember that the number is in points squared; do not describe it as a pixel diameter or as a distance in x, y, or z units.

Because 3D scenes are projected onto a 2D display, apparent marker size also depends on overlap and viewpoint. A point farther back in the scene is still rendered by the same size parameter, but the projection can make visual comparisons less intuitive than in a flat chart.

Using the argument with common scatter options

s can be supplied alongside normal scatter options such as color and transparency:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • 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
ax.scatter(
    x,
    y,
    z,
    s=50,
    c=[0.1, 0.4, 0.7, 0.8, 1.0],
    cmap="viridis",
    alpha=0.8,
)

These options control different properties. s controls marker size, c and cmap control coloring, and alpha controls transparency. Changing color or transparency will not change the size value, so keep s explicit when size is important to your chart.

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

Editing code that already creates the axes

Many scripts create the axes in one statement and call scatter later. You only need to edit the latter:

fig = plt.figure(figsize=(7, 5))
ax = fig.add_subplot(111, projection="3d")

# Existing data and styling remain unchanged
ax.scatter(x, y, z, s=65, color="steelblue", alpha=0.75)
plt.show()

The positional form add_subplot(111, projection="3d") and the shorter add_subplot(projection="3d") both create a 3D axes. The marker-size change is still made on ax.scatter, regardless of which subplot syntax your script uses.

Troubleshooting marker-size problems

The markers did not change

  • Confirm that the edited line is the one that actually runs. In a script with several scatter calls, each call creates its own collection and must receive its own s value.
  • Check that s is spelled with a lowercase letter and is inside the scatter(...) call.
  • Make sure an old figure is not being displayed instead of the figure created after the edit. Re-run the cell or script that constructs the axes and call plt.show() after the updated scatter call.

An array of sizes raises an error or does not align

Verify that the size array has one entry for every point in the plotted data. If you remove rows from x, y, and z, apply the same filtering to the size array. If you sort the coordinates, reorder sizes with the same index order. A scalar avoids alignment issues when all markers should be identical.

The result is too small or too large

Change the numeric value and render the figure again. Because s is an area-like points-squared value, doubling the number does not mean a marker with exactly twice the visual diameter. Compare a few values in the final output rather than trying to convert the value to pixels.

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

The code creates a flat plot instead of a 3D plot

Inspect axes creation. It must include the 3D projection, for example:

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 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.
ax = fig.add_subplot(projection="3d")

Then call the 3D axes method:

ax.scatter(x, y, z, s=40)

If the axes was created as a normal 2D subplot, the 3D call pattern will not be available in the expected form.

Version and 3D-rendering considerations

The cited API page is the Matplotlib 3.11.2 stable documentation. Its signature shows Axes3D.scatter(xs, ys, zs=0, zdir='z', s=20, ...), with s accepting a float or array-like value. Defaults and signatures can change between releases, so check the documentation corresponding to the Matplotlib version installed in your environment if behavior differs.

Matplotlib’s mplot3d toolkit overview describes the toolkit as a 2D projection of a 3D scene and notes that 3D plotting is less mature than the 2D case. That limitation affects depth ordering and visual interpretation, but it does not remove support for the s argument. You can still set a uniform or per-point marker size on Axes3D.scatter.

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

A reusable pattern for both sizing modes

Use a parameter in your own plotting function when you want to switch between a uniform size and data-driven sizes without changing the rest of the chart:

import matplotlib.pyplot as plt
import numpy as np

def scatter_3d(x, y, z, sizes=40):
    fig = plt.figure()
    ax = fig.add_subplot(projection="3d")
    ax.scatter(x, y, z, s=sizes)
    return fig, ax

x = np.array([1, 2, 3, 4])
y = np.array([2, 4, 1, 3])
z = np.array([0, 1, 3, 2])

# One value for every point
fig, ax = scatter_3d(x, y, z, sizes=40)
plt.show()

# One value per point
fig, ax = scatter_3d(x, y, z, sizes=np.array([15, 30, 55, 90]))
plt.show()

Here, sizes=40 is a scalar in the first call, while the second call supplies an array-like sequence. Both calls use the same 3D axes setup and coordinate data.

Final checklist

  • Add s=value to the ax.scatter(x, y, z, ...) call.
  • Use a scalar for one size across all points.
  • Use an array-like with one aligned value per point for variable sizes.
  • Interpret values as points squared, not pixels or data units.
  • Remember that omitting s uses the documented default of 20 for Matplotlib 3.11.2.
  • Create the axes with projection="3d" when starting a new plot.
  • Tune the number against the final figure size and viewpoint instead of assuming one universal 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.