Color from surf and colorbar doesn't match
2 views (last 30 days)
Show older comments
I am using 'surf' to create a 3D surface plot. However, the color in the plot does not match what is shown in color bar. Here is the code, please help.
if true
r = (1:0.01:3);
m = length(r);
theta = linspace(0,2*pi,721);
n = length(theta);
for i=1:m
for j=1:n
x(i,j) = r(i)*cos(theta(j));
y(i,j) = r(i)*sin(theta(j));
z(i,j) = r(i)^2;
end
end
surf(x,y,z)
colorbar
end
0 Comments
Answers (1)
Star Strider
on 28 Jun 2017
The color does match when I run it in R2017a, and use mesh instead of surf to do the plot.
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!