scatter plot on top of surface has garbled points
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mkarikom
am 15 Mai 2020
Kommentiert: Ameer Hamza
am 15 Mai 2020
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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 15 Mai 2020
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;
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!