1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica - Colour each 2D point by a third coordinate for each point?

  1. Apr 22, 2009 #1
    I'm looking, as an observer, at imaging accretion discs and tori around Kerr black holes. The image of the disc/torus is projected onto a 2D grid (a CCD if you like) so all lensing effects etc. are implicit. Basically, I can plot the image after determining the (x,y) coordinates in the 2D grid. Plotting 2D data using ListPlot and using the Import command for my .dat files (which are a list of (x,y) points) is no problem.

    My question is this: How would one plot a list of (x,y,z) data in ListPlot, where each pixel/point is plotted as (x,y) and the third coordinate z (which can represent redshift, radial coordinate etc) is used to colour each pixel, i.e. its corresponding (x,y) coordinates?

    Thank you
  2. jcsd
  3. Apr 23, 2009 #2
    I don't mind if anybody could tell me how to do this in IDL instead of Mathemtica say? I can use IDL on my university computers also. Anybody, please?
  4. Apr 23, 2009 #3
    Using Mathematica, suppose your list is in the form L = {{x1,y1,z1},{x2,y2,z2},...,{xN,yN,zN}}, then you could generate a colored graphic using this snippet of code:

    Graphics[{Hue[#3], Point[{#1, #2}]} & @@@ L, Frame -> True]

    I am not sure how you want to turn your z coordinates into colors, so play around with the Hue function.

    Also, although I love Mathematica and recommend it all the time, IDL is the best tool for producing astronomical plots e.g. some astro quirks like smaller magnitudes being brighter stars cause trouble when you try to make Mathematicaplot the y axis with positive values below the x axis and negative values above the x axis.
    Last edited: Apr 23, 2009
  5. Apr 26, 2009 #4
    Thanks ExactlySolved, I think I've got it. Well, re: the redshift, I know hue varies between 0 and 1 and I'm playing with it right now. I want my negative redshifts to be coloured shades of green to blue and my positive redshifts shades of yellow-orange-red for increasing z. I've been playing with this for a few hours but have not, as of yet, figured out how to do this.

    However, I now have nice colours, which is a start! Thank you again.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook