How to make circular colormap surf plot
11 views (last 30 days)
Show older comments
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);
0 Comments
Answers (3)
Mike Garrity
on 30 Jun 2015
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.
0 Comments
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!