Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fivetoadsloth

macrumors 65816
Original poster
Aug 15, 2006
1,035
0
Hey,

I have a 122x122 matrix saved as a .csv file. The values in each cell range from about -2 to +19 and I'm trying to incorporate a colors gradient were depending on the value the cell is assigned a separate color. Another option would be using a 3 column data set and attempting a listplot where the first two points plot the point an the third somehow assigns the color.

Mathematica would be ideal, since I am relatively familiar with the software, though if R is going to b easier, I'm open to exploration- I'll just need more instruction.


Thanks a lot, if someone has any better ideas as to how to execute this let me have them!

Thanks.

Edit: I think one of the Excel surface plots may also work. When I create it though, it groups all of the cell values in 3 different ranges. Is there a way for me to change this so I can have quite a few more, and preferably be able to dictate the color for each range.
 
I'm not sure exactly what you want, but perhaps this is a "gray-scale" approximation (in Mathematica):

Code:
DataMatrix = RandomInteger[{-2, 19}, {122, 122}];

Show[Table[
  Graphics[{RGBColor[(DataMatrix[[i, j]] + 2)/
      21, (DataMatrix[[i, j]] + 2)/21, (DataMatrix[[i, j]] + 2)/21], 
    Rectangle[{i, j}]}], {i, 1, 122}, {j, 1, 122}]]

A .pdf of the Mathematica .nb file is attached.
 

Attachments

  • Gradient.pdf
    241.7 KB · Views: 165
Thanks a lot! I manipulated the code a bit and got something much closer to what I wanted then I had before. I'll see if I can figure out how to implement color.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.