Python: Can a 3d plot made from a list of data points have a gradient color scheme? -


i have list of points plotted in 3d, , have gradient color scheme plot. possible? if so, how can done? tried of examples on matplotlib site none of them worked.

datagrid.txt made of 3 columns of numbers x,t,u 3 column vectors respected columns in txt file.

from mpl_toolkits.mplot3d import axes3d import numpy np import pylab  x, t, u = np.loadtxt("datagrid.txt", unpack = true)  fig = pylab.figure() ax = fig.add_subplot(111, projection = '3d') ax.plot(x, t, u) pylab.show() 

enter image description here

instead of ax.plot, try ax.plot_surface.

edit

after discussions op, found out data given in 1d column vectors, plot_surface expects 2d arrays. data grouped x values, each x value has 701 increasing values of t. data had reshaped 2d arrays so:

x = x.reshape((-1, 701)) t = t.reshape((-1, 701)) u = u.reshape((-1, 701)) 

then, gradient requires specifying colormap:

ax.plot_surface(x, t, u, cmap=pylab.get_cmap('jet')) 

where 'jet' colormap requested. list of colormaps matplotlib available here.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -