python - 曲面图上的连续颜色图
问题描述
我想在 3D Surface Plot 上使用 matplotlib 创建一个连续的颜色图,其中颜色取决于表面的 z 值。但是使用“正常” plt 函数,颜色图会用相同的颜色填充网格点之间的空间,如图所示。所以颜色没有连续变化,而只是一些彩色表面缝合在一起:
x = range(0,126)
y = range(0,3)
#z is my data from the experiment
# make a grid of the x/y plane
X,Y= np.meshgrid(x,y)
# get the colormap for the graph
cmap=plt.get_cmap("RdBu")
# cmap = clr.LinearColormap.from_list('custom blue', ['#244162','#DCE6F1'], N=256)
#plot the corresponding z-value at every knot of the grid
surface = ax.plot_surface(X,Y,z, cmap = cmap, antialiased=True, edgecolor='gray' , linewidth=0.2)
m = cm.ScalarMappable(cmap=surface.cmap,norm=surface.norm)
m.set_array(z)
plt.colorbar(m)
ax.set_yticks(y)
ax.set_xticks(x[::25])
plt.show()
看起来像这样: 3D-surface Plot
我是否需要在其间插入更多网格点的表面,还是有更优雅的方法?我对文档和语法有点迷茫
在此先感谢,masterblibla
解决方案
推荐阅读
- linux - 如何在启动期间禁用串行控制台
- r - 在循环中呈现动态加载的 UI 仅显示最后一个值
- android - 如何从android中的firebase中删除单个孩子?
- xaml - 如何在标签页之前添加内容页或视图
- database - 如何关闭数据库 sybase v 15.7?
- r - 带有 R 的地图:无法更改点/坐标的投影
- jquery - 重新触发引导通知功能后,对话框不应出现两次(或更多)
- hibernate - 如何创建 lucene 查询,它应该给出只匹配给定两个字段的两个给定值的对象?
- sql - 如何在 DB2 的 where 子句中使用动态 AND 或 OR 运算符?
- eclipse - 如何让eclipse IDE更灵活?