scatter plot on top of surface has garbled points
6 次查看(过去 30 天)
显示 更早的评论
I have the following code that overlays a scatter plot on a surface.
Notice that some of the rounded points are chopped off.
figure
scatter(rand(20,1)*10,...
rand(20,1)*20,...
'o', 'LineWidth',5, ...
'MarkerFaceColor', 'black', ...
'MarkerEdgeColor', 'black')
hold on
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)
view(2)
axis equal square;
Here is the output:
0 个评论
采纳的回答
Ameer Hamza
2020-5-15
You are using surf(), which plots a 3D surface. scatter() draws points at z=0, so if the surface lies above, or intersect the point, it becomes invisible or partially visible. Since you are using view(2), so there is no need to create a 3D surface. You can get same visual using pcolor
figure
hold on
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
pcolor(X,Y,Z)
view(2)
scatter(rand(20,1)*10,...
rand(20,1)*20,...
'o', 'LineWidth',5, ...
'MarkerFaceColor', 'black', ...
'MarkerEdgeColor', 'black')
axis equal square;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!