필터 지우기
필터 지우기

Polar fill sector

조회 수: 31 (최근 30일)
Jay
Jay 2011년 6월 19일
편집: Toshia M 2024년 4월 30일
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.

답변 (3개)

Toshia M
Toshia M 2024년 4월 30일
편집: Toshia M 2024년 4월 30일
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")

Walter Roberson
Walter Roberson 2011년 6월 19일
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
Naor Movshovitz
Naor Movshovitz 2016년 11월 15일
@Walter any chance this approach can be improved upon using the new (R2016a) polar axes object?
Walter Roberson
Walter Roberson 2016년 11월 15일
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
Gurudatha Pai 2011년 6월 19일
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
Walter Roberson
Walter Roberson 2011년 6월 19일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by