Polar fill sector
34 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (3)
Toshia M
el 30 de Abr. de 2024
Editada: Toshia M
el 30 de Abr. de 2024
Starting in R2024a, you can use the polarregion function to create a polar rectangle with specific bounding angles and radii. For example:
thetas = [pi/8 2*pi/8];
radii = [1 2];
figure
polarregion(thetas,radii)
By default, the rectangle is a semitransparent gray, but you can optionally specify the color and add a border around the rectangle. For example, you can create a blue rectabgle with a black border:
figure
polarregion(thetas,radii,FaceColor="blue",EdgeColor="black")
0 comentarios
Walter Roberson
el 19 de Jun. de 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 comentarios
Naor Movshovitz
el 15 de Nov. de 2016
@Walter any chance this approach can be improved upon using the new (R2016a) polar axes object?
Walter Roberson
el 15 de Nov. de 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
el 19 de Jun. de 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!
1 comentario
Walter Roberson
el 19 de Jun. de 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.
Ver también
Categorías
Más información sobre Polar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!