Matplotlib: GRID and COLORMAP with TRISURF

流过昼夜 提交于 2021-01-29 20:50:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!