简体   繁体   中英

Custom colormap in matplotlib for 3D surface plot

I have a surface plot with a specified colormap. Following is how I get it:

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)

This is my result:

在此处输入图片说明

I want the colorbar values to range from 0.5 - 1.0 instead of the default 0-1. How should I approach this?

m.set_clim(vmin=0.5, vmax=1.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM