Matplotlib: how can I convert a XYZ scatter to a pixel image?

Okay - there are two ways that you can do this. One would be for you to have a discreet number of bins for the distances (like d 20pc). This is relatively easy, all you need to do are a few loops - here is an example with 3: raclose = ramid = rafar = decdlose = decmid = decfar = for ii in range(len(dist)): if distii 20.

: rafar. Append(raii) decfar. Append(decii) else: ramid.

Append(raii) decmid. Append(decii) plt. Clf ax1 = scatter(raclose, decclose, marker='o', s=20, color="darkgreen", alpha=0.6) ax2 = scatter(ramid, decmid, marker='o', s=20, color="goldenrod", alpha=0.6) ax3 = scatter(rafar, decfar, marker='o', s=20, color="firebrick", alpha=0.6) line1 = Line2D(range(10), range(10), marker='o', color="darkgreen") line2 = Line2D(range(10), range(10), marker='o',color="goldenrod") line3 = Line2D(range(10), range(10), marker='o',color="firebrick") plt.

Legend((line1,line2,line3),('d d > 10pc', 'd > 20pc'),numpoints=1, loc=3) show() Or you can do a contour plot, such that you stipulate RA on the x-axis and Dec on the y-axis and fill in the plot with the distances. Both RA and Dec are 1D arrays with the respective coordinates. Then you make a 2D array with the distance.

Determine what the median/mean value of the distances are and then divide the 2D array by that value to normalize it. Finally, plot using a contour plot (using contourf or imshow), like: import matplotlib. Pyplot as plt from matplotlib import cm ax = pylab.

Contourf(RA,Dec,dists, levels=1, 5, 10, 15, cmap=plt.cm. Spectral) cbar=pylab.colorbar().

Thanks, for the help -- have got something similar to your second solution working. Am building up a 2D array and inputting it into imshow. Thanks again!

– aim Nov 5 at 13:24 Oh good! I use the second solution in a number of my own routines, but realized it was a little more complicated than perhaps you would have wanted. Glad you got it working.

– cosmosis Nov 5 at 19:41.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions