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

2 visualizzazioni (ultimi 30 giorni)

Risposte (2)

Star Strider
Star Strider il 10 Nov 2023
Modificato: Star Strider il 10 Nov 2023
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 il 10 Nov 2023
See my attached colorwheel demo. You can vary things like inner and outer radius, number of colors, etc.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by