MATLAB Answers


How to apply colourmap onto shapes

Asked by Gautam Ilango on 31 Aug 2017
Latest activity Answered by José-Luis
on 31 Aug 2017

I would like to set the colour of each circle according to a given value. (See attached image) The graph must contain this matrix of circles coloured using colourmap.

How do I draw the circles and apply the colourmap to them?

  1 Comment

on 31 Aug 2017
The answer to what is in your question title would be fairly trivial if you actually had the representation of the shapes, but in the body of your question you casually tag on asking how to draw the circles in the first place, which is less easy (or at least not something I am familiar with doing). I would imagine you can parameterise a patch object with the parametric description of a circle, but it's not something I've ever needed to do.

Sign in to comment.

1 Answer

Answer by José-Luis
on 31 Aug 2017
 Accepted Answer

radius = 2;
c_x = 1;
c_y = 1;
numElem = 100;
x = linspace(0,2*pi,numElem);
y = x;
x = radius.*cos(x) + c_x;
y = radius.*sin(y) + c_y;
axis equal


Sign in to comment.