MATLAB >> Filling an area in a polar plot, how do I do this?

by Sadik » Thu, 18 Feb 2010 23:18:02 GMT

There could be better solutions but the one that comes to my mind is the following.

If you sample your polar plot densely enough, the you can use patch. It will not be an exact fill but it may look almost filled.

Please do

help patch

Best.

"yaya yoyo" < XXXX@XXXXX.COM > wrote in message <hljg5a$qd3$ XXXX@XXXXX.COM >...
> Hello all,
> I want to fill in part of the circle in a polar plot but don't know exactly how to do so?
> Specifically, I measured the head direction of an animal and computed the preferred head direction. Which I represent using a polar plot. In addition to this I want to show the confidence interval for my measure (which I also already computed) . The way I wanted to do so, was to highlight this area of the polar plot some how,
> In regular plots I can do this using functions such as area and others, but I have no idea how I can do this in the polar plots and would appreciate you help,
> Thank you

MATLAB >> Filling an area in a polar plot, how do I do this?

by Walter Roberson » Fri, 19 Feb 2010 03:12:02 GMT



h = polar([pi/6,pi/5],[1 2]);
paxis = get(h,'Parent');
paxchild = allchild(paxis);
ppatch = paxchild(end);

ppatch will now be the handle of a patch which is the circle of the polar
plot. You can get the patch's XData and YData properties in order to retrieve
the *cartesian* coordinates of the circle (relative to the axis). The
coordinates are counter-clockwise starting from the right-most point on the
circle (x = whatever, y = 0). There will probably be 101 coordinates, with the
last pair being the same as the first. If you have angle alpha degrees, then
it will touch the circle between pairs floor(1 + 100 * alpha / 360) and
ceil(1 + 100 * alpha / 360). You could interpolate the coordinates if you feel
enthusiastic.

With this information, you can create a patch from (0,0) to the first
(counter-clockwise) point, then copy the points from the patch until you reach
the last exact point, then add your interpolated final point, then close back
to (0,0).

Warning: if you are using the OpenGL renderer, in order for the second patch
to appear on top of the patch that is the circle, you must give the second
patch a Z value that is greater than the (implicit 0) Z value of the
background circle. It doesn't matter which of the patches is drawn "first",
and manipulating the axis Children order or using uistack() will not change
this behavior: it is a property of OpenGL that items in the same Z plane are
internally rendered in a specific order.

MATLAB >> Filling an area in a polar plot, how do I do this?

by Jerry Gump » Fri, 21 May 2010 04:47:04 GMT

Can you do this example?

angle = [0,0,pi/2];
radius = [0, 2, 2];
h = polar(angle,radius);

It is a triangle on a polar plot. How do you fill this triangle with color?

Thanks.

MATLAB >> Filling an area in a polar plot, how do I do this?

by Walter Roberson » Fri, 21 May 2010 05:06:04 GMT


patch( get(h,'XData'), get(h,'YData'), 'g')

Easy ;-)

Similar Threads

1. MATLAB User Feedback Survey: Re-post (Please fill out if you have not done so already) - MATLAB

2. MATLAB User Survey: Re-post (Please fill out if you have not done so already)

3. How can it be done ? ( plot prob ) - MATLAB

4. Out of Memory when doing 3D plot

Hi,

I'm trying to plot some 3D data using mesh(X,Y,Z). Basically, X and Y
are column vectors of length 4000 each. Z needs to be a matrix of
size(length(Y) ,length(X)) which would make it 4000 X 4000. When I
try to run the code, it says out of meemory error. has anyone had
problems plotting this amount of data? Is there a way to make this
more efficient?

I would really appreciate any help!

5. Polar plots square filled colors - MATLAB

6. area plot (not filled in)?

I want to create several plots on one axes, of perhaps many different
types (stacked bar, bar, area, line); I am using the hold all
function. For the area, I would like it not to be filled in, but to
have the lines be the fillin color. there must be an easy way to do
this!

Thanks
meggie

7. Fill the area under a plot? - MATLAB

8. Area plot with intensity fill

Hi Folks,

I have distance from shore values (X) that I plot depth values (Y)
against. I plot this as an area plot.

For each Y value (depth), I have a third value (e.g. temperature or
salinity) that I want to display as the intensity of colour that Y is
shown in. I.e., I want the fill colour for each Y-value to match a
third variable. Can I do this?

Thanks for your help.