# Coloring circles based on radius

I have a list of ellipses with x and centroid, orientation, and major diameter and minor diameter. I currently have them overlaid on an image in red but what I would like is to be able to colour them based on their orientation (keeping in mind that the orientation is now always positive but is bound by -180 < theta < 180 degrees).

Ideally I would like to both be able to colour them as a continuous function as well as by discrete bounds, ie. If -1 < orientation < 0 -> Blue, 0 < orientation < 1 -> Red. etc.

Any help would be greatly appreciated. I've appended a very small sample of my data set.

Thanks, Andrew.

SampleData = {{13717.3, 1101.24, -0.470674, 204.482, 26.6952}, {9772.62,
1100.88, -0.350601, 213.606, 26.4938}, {13102., 1100.25, -0.100438,
167.739, 27.9001}, {13519.1, 1100.84, -0.117897, 196.044,
27.1261}, {10499.7, 1100.56, -0.0433213, 231.682,
26.8481}, {12475.2, 1100.51, -0.000615264, 208.972,
27.7002}, {10285.5, 1100.21, -0.109259, 189.952, 25.066}, {12144.,
1098.06, -0.683868, 152.963, 24.2331}, {14052., 1097.97, -1.14783,
215.054, 24.9059}, {9075.55, 1096., 0.302659, 277.09, 26.9322}};
Prepend[SampleData,{"X centroid","Y centroid","Orientation","Major Diameter","Minor Diamater"}]//TableForm

Visualization =
Graphics[{Red,Thickness -> 0.0025,
SampleData /. {({centroidx_, centroidy_, orientation_,
majordiameter_, minordiameter_}) :> {Rotate[
Circle[{centroidx, centroidy}, {majordiameter/2,
minordiameter/2}],
orientation*\[Pi]/180, {centroidx, centroidy}]}}
}
]


-1 < orientation < 0 -> Blue, 0 < orientation < 1 -> Red

Since your orientiation values appear to be between -1 and 1 this requirement translates to

Sign[orientation] /. {-1 -> Blue, 1 -> Red}


so:

Visualization =
Graphics[{Thickness -> 0.0025,
SampleData /. {({centroidx_, centroidy_, orientation_,
majordiameter_,
minordiameter_}) :> {Sign[orientation] /. {-1 -> Blue,
1 -> Red},
Rotate[Circle[{centroidx, centroidy}, {majordiameter/2,
minordiameter/2}],
orientation*\[Pi]/180, {centroidx, centroidy}]}}}]

• Perfect, thanks a lot. In case anyone else is interested in a more generic solution, by putting {ColorData["DarkBands"][Rescale[orientation, {lowerbound, upperbound}]]} instead of {Sign[orientation] /. {-1 -> Blue, 1 -> Red} I was able to get a continuous color function based on the radius. – Andrew Stewart Apr 8 '15 at 23:13