How can I set zero value to white? in mesh plot

35 visualizaciones (últimos 30 días)
niloofar rahmani
niloofar rahmani el 8 de Mzo. de 2023
Comentada: niloofar rahmani el 27 de Mzo. de 2023
I want to show zero values in white in the mesh plot so that all components with non-zero values are clearly visible.
my code is:
mesh(A) % A(1202*30)
colorbar
xlim([1 30])
I don't know how to set the colors.
  5 comentarios
niloofar rahmani
niloofar rahmani el 13 de Mzo. de 2023
I'm really sorry, I apologize so much.
Thanks a lot.
With best regards.
niloofar rahmani
niloofar rahmani el 27 de Mzo. de 2023
Thanks a lot

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 8 de Mzo. de 2023
Like Rik said, one option is to replace zeros with NaNs in A; then they won't show up at all (so by default you see the white axes underneath). I think this is probably the easiest option.
% random A: 60x30 matrix of integers from 0 to 5
A = randi([0 5],60,30);
% replace 0 elements with NaNs
A(A == 0) = NaN;
% create a surface
surf(A,'EdgeColor','none')
% or a mesh
% mesh(A)
% colormap, colorbar, view, grid, box
colormap(parula(12))
colorbar
view(2)
grid off
box on

Más respuestas (0)

Categorías

Más información sobre Line 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