scatter plot on top of surface has garbled points
조회 수: 7 (최근 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!