There is a cylinder

x=np.linspace(-1, 1, 100) z=np.linspace(0, 1, 100) Xc, Zc=np.meshgrid(x, z) Yc = np.sqrt(1-Xc**2) rstride = 20 cstride = 10 ax.plot_surface(Xc, Yc, Zc, alpha=0.2,linewidth=0) ax.plot_surface(Xc, -Yc, Zc, alpha=0.2,linewidth=0) 

There is also a list of points that need to be repainted. How can this be done? Maybe there is a suitable function?

Found an opportunity to paint, but for some reason the back side of the cylinder is incorrectly painted

 import math from matplotlib import pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection import numpy as np from matplotlib.colors import LightSource fig = plt.figure() ax = fig.add_subplot(111, projection='3d') #Построение цилиндра x=np.linspace(-1, 1, 100) z=np.linspace(0, 1, 100) Xc, Zc=np.meshgrid(x, z) Yc = np.sqrt(1-Xc**2) ############################ # Create light source object. ls = LightSource(azdeg=0, altdeg=65) # Shade data, creating an rgb array. rgb = ls.shade(Yc, plt.cm.RdYlBu) ############################ rstride = 20 cstride = 10 ax.plot_surface(Xc, Yc, Zc,facecolors=rgb, alpha=0.9,linewidth=0) ax.plot_surface(Xc, -Yc, Zc,facecolors=rgb, alpha=0.9,linewidth=0) ax.set_xlabel("X") ax.set_ylabel("Y") ax.set_zlabel("Z") plt.show() 
  • Can you give an example of points and explain how they need to be repainted? - MaxU
  • You need to create a simple light source. I decided to do it through the surface normal at each point and with a ray (which is defined by a point and a guiding vector). After that, looking for the angles between the normal vectors and the ray. It remains to be understood with the help of what to change color. Tk there are points and "coefficients" of color change - Ilshat Murzurbekov
  • Is matplotlib.colors.LightSource not suitable for your task? - Avernial
  • @Avernial Generally fits, but for some reason the back side is not completely painted over with black, I don’t understand why - Ilshat Murzurbekov
  • @Avernial added code in the first post - Ilshat Murzurbekov

0