Borrar filtros
Borrar filtros

scatter plot on top of surface has garbled points

7 visualizaciones (últimos 30 días)
mkarikom
mkarikom el 15 de Mayo de 2020
Comentada: Ameer Hamza el 15 de Mayo de 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:

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 15 de Mayo de 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 comentarios
mkarikom
mkarikom el 15 de Mayo de 2020
perfect, thank you
Ameer Hamza
Ameer Hamza el 15 de Mayo de 2020
I am glad to be of help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by