Shade a wedge/portion of a compass or polar plot?

조회 수: 3 (최근 30일)
Jared Saletin
Jared Saletin 2017년 1월 23일
편집: Adam Danz 2025년 6월 19일
Hi there!
I'm stumped on a question. I need to plot polar vectors from the origin on a polar axis. I can do this using either polarplot or compass without difficulty.
However I also need to shade a portion of the plot. So for instance, a complete wedge of the plot from 0 -> pi/2 shaded grey instead of background.
I tried to draw an arc, and use patch, but it didn't complete e full wedge.
Any ideas?
Jared

답변 (1개)

John Chilleri
John Chilleri 2017년 1월 23일
편집: John Chilleri 2017년 1월 23일
Hello,
I've found fill to be useful in this scenario, although it's slow, and I wouldn't recommend it if you plan to shade many many areas.
If you have the coordinates of the edges as vectors x and y (you'll start and finish at the origin I assume), then you can:
fill(x,y,C)
where C is your desired color.
I put this together real fast for the unit circle from 0 to pi/2:
x = [0 0:.01:1 0];
y = [0 sqrt(1-x(2:end-1).^2) 0];
fill(x,y,[.7 .7 .7])
axis([-1 1 -1 1])
It's colored gray and you can make it more or less detailed by changing the .01 value in the x vector.
Hope this helps!
  댓글 수: 1
Adam Danz
Adam Danz 2020년 7월 30일
편집: Adam Danz 2025년 6월 19일
fill() uses patch() which is not currently supported in polar axes.
R2025a update: patch and surfaces are now supported in polaraxes

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

카테고리

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