matplotlib 中用于 3D 曲面图的自定义颜色图
Custom colormap in matplotlib for 3D surface plot
我有一个带有指定颜色图的曲面图。以下是我的获取方式:
import numpy as np
import matplotlib.pyplot as plt
import math
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import plaque_vessel_models
# Model creation
ptX= []
ptY = []
ptZ = []
ptX1 = []
ptY1 = []
ptZ1 = []
pt_F = []
ang = np.linspace(0,2*np.pi,360)
x_list = [100,90,80,70,60,50,40,30,20,10,5]
for i in range(0,10):
x = []
y = []
z = []
pt = []
for t in range(0,len(ang)):
x.append(x_list[i]*math.cos(ang[t]))
y.append(50*math.sin(ang[t]))
z.append(i)
pt.append([x,y,z])
pt_F.append(pt)
ptX.append(x)
ptY.append(y)
ptZ.append(z)
# Surface plot
fig = plt.figure()
ax = Axes3D(fig)
C_l = plaque_vessel_models.curvature3D(np.array(ptX),np.array(ptY),np.array(ptZ),'m')
ax.plot_surface(np.array(ptX),np.array(ptY),np.array(ptZ),facecolors = cm.jet(np.array(C_l)),rstride=1, cstride=5,antialiased=False)
m = cm.ScalarMappable(cmap = cm.jet)
m.set_array(C_l)
fig.colorbar(m,shrink = 0.5)
这是我的结果:
我希望颜色栏值的范围为 0.5 - 1.0,而不是默认值 0-1。我该如何处理?
m.set_clim(vmin=0.5, vmax=1.0)
我有一个带有指定颜色图的曲面图。以下是我的获取方式:
import numpy as np
import matplotlib.pyplot as plt
import math
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import plaque_vessel_models
# Model creation
ptX= []
ptY = []
ptZ = []
ptX1 = []
ptY1 = []
ptZ1 = []
pt_F = []
ang = np.linspace(0,2*np.pi,360)
x_list = [100,90,80,70,60,50,40,30,20,10,5]
for i in range(0,10):
x = []
y = []
z = []
pt = []
for t in range(0,len(ang)):
x.append(x_list[i]*math.cos(ang[t]))
y.append(50*math.sin(ang[t]))
z.append(i)
pt.append([x,y,z])
pt_F.append(pt)
ptX.append(x)
ptY.append(y)
ptZ.append(z)
# Surface plot
fig = plt.figure()
ax = Axes3D(fig)
C_l = plaque_vessel_models.curvature3D(np.array(ptX),np.array(ptY),np.array(ptZ),'m')
ax.plot_surface(np.array(ptX),np.array(ptY),np.array(ptZ),facecolors = cm.jet(np.array(C_l)),rstride=1, cstride=5,antialiased=False)
m = cm.ScalarMappable(cmap = cm.jet)
m.set_array(C_l)
fig.colorbar(m,shrink = 0.5)
这是我的结果:
我希望颜色栏值的范围为 0.5 - 1.0,而不是默认值 0-1。我该如何处理?
m.set_clim(vmin=0.5, vmax=1.0)