0

I am trying to set the edge color in the plot of a surface where I have set facecolors. However, if I set the facecolors, we can't see the edges ...

If we take the example of matplotlib : and we add edgecolor='black', linewidth=1 we can't see the black edges ...

import matplotlib.pyplot as plt
from matplotlib.ticker import LinearLocator
import numpy as np


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

# Make data.
X = np.arange(-5, 5, 0.25)
xlen = len(X)
Y = np.arange(-5, 5, 0.25)
ylen = len(Y)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

# Create an empty array of strings with the same shape as the meshgrid, and
# populate it with two colors in a checkerboard pattern.
colortuple = ('y', 'b')
colors = np.empty(X.shape, dtype=str)
for y in range(ylen):
    for x in range(xlen):
        colors[y, x] = colortuple[(x + y) % len(colortuple)]

# Plot the surface with face colors taken from the array we made.
surf = ax.plot_surface(X, Y, Z, facecolors=colors, edgecolor ='black', linewidth=1)

# Customize the z axis.
ax.set_zlim(-1, 1)
ax.zaxis.set_major_locator(LinearLocator(6))

plt.show()

image of the plot

How can I resolve this issue ?

Note : My final goal is to plot on a complex surface the value of the curvature at each point with facecolors=plt.cm.jet(norm(gauss)) and also to see the edge on the same plot.

  • Calling `surf.set_edgecolors('black')` after `surf = ax.plot_surface(...)` seems to work better. – JohanC Feb 28 '23 at 12:05

0 Answers0