python - Using a separate function for colormap other than x,y,z for a 3D surface -


i'm generating 3d shape (x1,y1,z1) using code below. separate function, a5, has been used colormap. of i'm getting blue surface. range of values in z1 higher of a5 - reason behind code generating blue surface? take limit of z1 facecolor? if how should use plot_surface purpose?

surf = ax.plot_surface(x1,y1,z1,rstride=1, cstride=1, linewidth=0, facecolors=plt.cm.jet(a5),antialiased=false) m = cm.scalarmappable(cmap=cm.jet) q=[-col,col] m.set_array(q) plt.colorbar(m) 

import numpy np import matplotlib import matplotlib.pyplot plt mpl_toolkits.mplot3d import axes3d  # generating data x, y = np.meshgrid(np.linspace(-1,1,101), np.linspace(-1,1,101)) z = x+y  # z plane r = np.sqrt(x*x+y*y) w = 2*np.cos(5*r)**2-np.sin(6*x) # w funny trig func  # initializing colormap machinery norm = matplotlib.colors.normalize(vmin=np.min(w),vmax=np.max(w)) c_m = matplotlib.cm.spectral s_m = matplotlib.cm.scalarmappable(cmap=c_m, norm=norm) s_m.set_array([])  # figure , 3d subplot fig = plt.figure() ax = fig.add_subplot(111, projection='3d')  # actual plot, note create facecolors array # i've used norm function instantiated above ax.plot_surface(x, y, x+y, linewidth=0,                 rstride=1, cstride=1,                 facecolors=s_m.to_rgba(w))  # draw colormap using scalarmappable instantiated above , shoe plt.colorbar(s_m) plt.show() 

enter image description here


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -