79479994

Date: 2025-03-03 01:04:51
Score: 2
Natty:
Report link

I thought this might work but it doesn't render properly.

Create a sphere with no lines. Then add circles.

import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.art3d as art3d
from matplotlib.patches import Circle

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

# Make data
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))

# Plot the surface
ax.plot_surface(x, y, z, color='w', shade=0)

# Add a circle
p = Circle((0, 0), radius=10, facecolor="none", edgecolor='k')
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z=0, zdir="z")

# Set an equal aspect ratio
ax.set_aspect('equal')

plt.show()

image of the matplotlib figure

You can make it slightly more believable by making both objects transparent but it still might not be what you wanted.

enter image description here

Does anyone know if matplotlib can correctly render objects that overlap?

Reasons:
  • RegEx Blacklisted phrase (2): Does anyone know
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-2):
Posted by: Bill