[AstroPy] scatter plot+colorbar

gonghang.naoc ghang.naoc at gmail.com
Thu Jun 4 09:49:47 EDT 2015


Hi all,
I have a three column data set, x, y, and colorvalue. How to show the
colorvalue for every point?

I tried the code below, but it does not work.  The colorbar appears, but
all points have the same color.

#############
import numpy as np
import pylab as pl
x,y,colorvlaue=np.loadtxt(dataset',usecols=(0,1,2),delimiter=",",unpack=True)
pts=pl.scatter(x,y,s=0.1,c=colorvalue,cmap=pl.cm.jet)
cb = pl.colorbar(pts)

cmin,cmax = cb.get_clim()
ticks = np.linspace(cmin,cmax,10)
cb.set_ticks(ticks)

pl.show()
################
Could anybody specify the error in the code above?

Thank you.
Hang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150604/5731e3c1/attachment.html>


More information about the AstroPy mailing list