# Polar fill sector

28 views (last 30 days)
Jay on 19 Jun 2011
Commented: Walter Roberson on 15 Nov 2016
Hey. I wanted to fill a sector of a polar graph with a specified colour. For example, say I wanted to create a polar plot and fill the area 1<r<2, pi/8 < theta < 2pi/8 with the colour [0 1 1], how would I code this. Is this possible? I need to fill many sectors so there will be a list of them.

Walter Roberson on 19 Jun 2011
Unfortunately the way to do this would be to construct a point list of boundary points, pol2cart() them, and fill() the cartesian polygon.
The point list would have to be relatively dense along theta in order to get nice curves, but the edges of the wedges could just have the two endpoints as those translate in to a straight line in cartesian space.
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 15 Nov 2016
How odd!
If you record the output from polarplot() that was allowed to create its own polar axes, then the output is type Line, class class matlab.graphics.primitive.Line . And it will have a bunch of properties including ThetaData and RData. If, inside that polar axes, you use line(), then you get one of those type of lines with that class and those properties.
If you record the output from line() in a normal axes, then the output is type Line, class matlab.graphics.primitive.Line -- exactly the same type and class. But it has XData and YData properties, not RData and ThetaData properties.
Now, if you set the Parent of a normal line to be a polar axes then it suddenly changes flavor into one suited for polar !
Ah... ah... looks like the difference is in how they display! Both objects have both property pairs and they are tied together, but if the parent is a polar axes then the polar variants are displayed and otherwise the XY variants are displayed

Gurudatha Pai on 19 Jun 2011
I was just wondering if the pie chart could be intelligently used to obtain the same result. @Walter: You would probably know better about modifying pie charts!
Walter Roberson on 19 Jun 2011
I think that approach would be longer.
The documentation for pie() indicates that patches are created. Those patches always come to a point, and so would have to be modified to instead follow the inner radius. Then you would have to add the radial and angular axes lines and notations. Easier to pol2cart() and fill() vectors.