How to draw a semi circle filled with jet color (like in the image) ?

조회 수: 2 (최근 30일)
Ignacio Alcala
Ignacio Alcala 2023년 11월 10일
답변: Image Analyst 2023년 11월 10일

답변 (2개)

Star Strider
Star Strider 2023년 11월 10일
편집: Star Strider 2023년 11월 10일
Try this —
N = 250;
th1 = linspace(pi, 3*pi/2, N);
r = linspace(0, 1, N);
z = r;
x1 = r(:)*cos(th1);
y1 = r(:)*sin(th1);
z1 = r(:)*ones(1,N);
figure
surf(x1,y1,z1, 'EdgeColor','none')
axis('equal')
colormap(jet(N))
view(0,90)
xtxt = linspace(min(xlim), max(xlim), 4);
text(xtxt, ones(1,4)*max(ylim), compose('$%2d^{\\circ}$',[15 10 5 0]), 'Vert','bottom', 'Horiz','right', 'FontSize',15, 'Interpreter','latex')
Ax = gca;
Ax.Visible = 'off';
N = 250;
th2 = linspace(pi/2, 3*pi/2, N);
r = linspace(0, 1, N);
z = r;
x2 = r(:)*cos(th2);
y2 = r(:)*sin(th2);
z2 = r(:)*ones(1,N);
figure
surf(x2,y2,z2.', 'EdgeColor','none')
axis('equal')
colormap(jet(N))
view(0,90)
axis('padded')
Ax = gca;
Ax.Visible = 'off';
text(1.2*cos([3 2 1]*pi/2), 1.2*sin([3 2 1]*pi/2), [1 1 1], {'$\frac{3\pi}{2}$', '$\pi$', '$\frac{\pi}{2}$'}, 'Interpreter','latex', 'FontSize',26, 'Horiz','right', 'Vert','middle')
Make appropriate changes to get the desired result.
EDIT — Corrected typographical errors.
.

Image Analyst
Image Analyst 2023년 11월 10일
See my attached colorwheel demo. You can vary things like inner and outer radius, number of colors, etc.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by