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

Click For Summary

Discussion Overview

The discussion revolves around plotting 2D data points in Mathematica, specifically how to visualize a list of (x,y,z) coordinates where the third coordinate (z) is used to determine the color of each point on a 2D grid. The context includes applications in astrophysics, particularly in imaging accretion discs and tori around Kerr black holes.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant describes their goal of plotting (x,y,z) data in Mathematica and seeks advice on how to color each point based on the z coordinate, which could represent various physical quantities like redshift.
  • Another participant suggests a code snippet for generating a colored graphic in Mathematica using the Hue function, but notes uncertainty about how to effectively map z values to colors.
  • A participant expresses a preference for using IDL for astronomical plots, citing specific challenges with Mathematica related to plotting conventions in astronomy.
  • One participant shares their progress in using colors based on redshift values, indicating a desire to use shades of green to blue for negative redshifts and shades of yellow-orange-red for positive redshifts, but mentions ongoing difficulties in achieving this.

Areas of Agreement / Disagreement

Participants express varying preferences for software tools (Mathematica vs. IDL) and there is no consensus on the best method for color mapping based on z values. The discussion remains unresolved regarding the optimal approach to achieve the desired color effects.

Contextual Notes

There are limitations in the discussion regarding the specifics of how to map z values to colors effectively, as well as the potential challenges faced when using different software tools for astronomical data visualization.

Ruf30
Messages
8
Reaction score
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
 
Physics news on Phys.org
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?
 
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:
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 7 ·
Replies
7
Views
6K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K