필터 지우기
필터 지우기

How to make circular colormap surf plot

조회 수: 7 (최근 30일)
Joshua Swann
Joshua Swann 2015년 6월 29일
답변: Chad Greene 2016년 5월 9일
Hello, I'm trying to make either a circular colormap surf plot or draw a circle on a square colormap surf plot. Below is what I've tried with drawing a circle, but only a few points are showing up. Thanks.
Center = 53.0; NaN = 49.8;
X = [-3.5 -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5,... -3.5, -2.33, -1.167, 0, 1.167, 2.33, 3.5]; Y = [ 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, ... 2.33, 2.33, 2.33, 2.33, 2.33,2.33,2.33,... 1.167, 1.167, 1.167, 1.167, 1.167,1.167,1.167,... 0, 0, 0, 0, 0, 0, 0,... -1.167, -1.167, -1.167, -1.167, -1.167, -1.167, -1.167,... -2.33, -2.33, -2.33, -2.33, -2.33, -2.33, -2.33,... -3.5,-3.5,-3.5,-3.5,-3.5,-3.5,-3.5,]; Z = [NaN,NaN,NaN,51.3,NaN,NaN,NaN,... NaN, 50.5, 51.6, 52.2, 51.7, 51.1,NaN,... NaN,51.4, 52.5, 52.9, 52.4, 51.6,NaN,... 49.8,51.5, 52.5, 53, 52.5, 51.7,49.9,... NaN,51, 52, 52.5, 52.1, 51.1,NaN,... NaN,49.9, 51.2, 51.6, 51.2, 50.3,NaN,... NaN,NaN,NaN,50.0,NaN,NaN,NaN,]/Center;
X = reshape(X,7,7); Y = reshape(Y,7,7); Z = reshape(Z,7,7);
figure;
r = 3.5; % Radius of the sample [cm] ang=0:0.01:2*pi; xp=r*cos(ang); yp=r*sin(ang); h2 = plot(xp,yp, 'c');
hold on
colormap hot h1 = surf(X,Y,Z, 'facecolor','interp', 'edgecolor', 'none'); view(2), colorbar, axis equal tight grid on set(gca,'layer','top', 'tickdir', 'out', 'linewidth', 1.5);

답변 (3개)

Mike Garrity
Mike Garrity 2015년 6월 30일
The surface has a range of Z values, and the circle is ending up behind it.
If you're using R2014b or later, you can turn off the depth sorting like so:
h1 = surf(X,Y,Z, 'FaceColor','interp', 'EdgeColor', 'none');
colormap hot
hold on
h2 = plot(xp,yp, 'c');
set(gca,'SortMethod','childorder')
I reversed the order of your surf & plot calls so that the plot would draw over the surf.
If you're using an earlier version, your best bet is probably to change the plot to plot3 and add a large Z value. That will move your plot in front of your surf.

Star Strider
Star Strider 2015년 6월 30일
I created a color wheel in my Answer to an earlier Question.

Chad Greene
Chad Greene 2016년 5월 9일
I wrote a phasebar function for this, which should do the trick.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by