Plot scatter points on 3d plot without axes and grids in Matplotlib

To plot scatter points on a 3D plot without axes and grids in Matplotlib, we can use the scatter() method and turn off the axes using axis('off'). This creates a clean 3D visualization focused entirely on the data points.

Steps

  • Set the figure size and adjust the padding between and around the subplots
  • Create a new figure using figure() method
  • Add a 3D subplot using add_subplot(projection="3d")
  • Generate x, y, and z data points using NumPy
  • Use scatter() method to create the 3D scatter plot
  • Use ax.axis('off') to hide axes and grids
  • Display the figure using show() method

Example

Here's how to create a 3D scatter plot without axes ?

import numpy as np
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig = plt.figure()
ax = fig.add_subplot(projection="3d")

# Generate random data points
xs = np.random.rand(100)
ys = np.random.rand(100) 
zs = np.random.rand(100)

# Create 3D scatter plot with color mapping
ax.scatter(xs, ys, zs, c=xs, cmap="copper")

# Hide axes and grids
ax.axis('off')

plt.show()

Additional Customization

You can further customize the plot by adjusting colors, sizes, and transparency ?

import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(projection="3d")

# Generate data with different patterns
xs = np.random.normal(0, 1, 200)
ys = np.random.normal(0, 1, 200)
zs = np.random.normal(0, 1, 200)

# Create scatter plot with custom styling
ax.scatter(xs, ys, zs, 
          c=zs,                    # Color based on z values
          cmap="viridis",          # Color map
          s=50,                    # Point size
          alpha=0.7)               # Transparency

# Remove all axes, grids, and labels
ax.axis('off')

plt.show()

Key Parameters

Parameter Description Example Values
c Color of points Array, color name, or colormap
cmap Colormap for color mapping "viridis", "copper", "plasma"
s Size of points Scalar or array
alpha Transparency level 0.0 (transparent) to 1.0 (opaque)

Conclusion

Using ax.axis('off') creates clean 3D scatter plots by removing axes, grids, and labels. This technique is perfect for focusing attention on data patterns without visual distractions.

Updated on: 2026-03-25T21:15:14+05:30

907 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements