# Array in Mathematica or R

Discussion in 'Mac Apps and Mac App Store' started by fivetoadsloth, Oct 2, 2010.

Joined:
Aug 15, 2006
#1
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.

2. ### LPZ macrumors 65816

Joined:
Jul 11, 2006
#2
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.