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

1 次查看(过去 30 天)

回答(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 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by