本文介绍了Matplotlib中Matlab的surf(x,y,z,c)等效于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Matlab中实现类似surf(x,y,z,c)的功能,这里xyz是坐标,而c是变量值,我可以使用c定义颜色.我不知道如何使用matplotlib来实现它.

I want to realize the function like surf(x,y,z,c) in matlab, here x,y and z are the coordinates, and c is a variable value, I can use c to define the color. I don't know how to realize it with matplotlib.

推荐答案

我已经使用类似这样的代码完成了此工作(请参见):

I've done it using code something like this (see Edgelines vanish in mplot3d surf when facecolors are specified):

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import matplotlib
from pylab import *
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')


#Create X and Y data
x = np.arange(xmin, xmax, xstep)
y = np.arange(ymin, ymax, ystep)
X, Y = np.meshgrid(x, y)


surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=C, antialiased=True)

#Show the plot
plt.show()

这篇关于Matplotlib中Matlab的surf(x,y,z,c)等效于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:10