问题
I want to put a grid on my surface but it doesn't work even with linewidth different from zero, also I would like to plot a colormap that changes the color with Z axis, so the walls should appear with the same color cos they are points at 0.5 in Z. Hope somebody can help me, thanks.
This is the part of my code I'm having problem with:
fig = plt.figure()
ax = Axes3D(fig)
surf = ax.plot_trisurf(x, y, z, cmap=plt.cm.get_cmap('jet',4), shade=False,linewidth=0.1, antialiased=False
)
This is my plot with a bad colormap and no grid
This is something similar to I want: with grid and a good colormap
回答1:
Is this you want?
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0, 50)
X, Y = np.meshgrid(t, t)
Z = np.zeros_like(X)
Z[:, 0] = 0.5
Z[:, -1] = 0.5
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, Z, cmap=plt.cm.get_cmap('jet',256), linewidth=0.2, antialiased=True)
来源:https://stackoverflow.com/questions/63832711/matplotlib-grid-and-colormap-with-trisurf