Colorbar with a range taken from a variable

2 visualizaciones (últimos 30 días)
Francesco
Francesco el 5 de Ag. de 2024
Comentada: Star Strider el 5 de Ag. de 2024
Hello,
I have a matrix organized in this way:
M= col1, col2.... col10
col1 and col2 are the x and y position of the data, col10 is a property of this data and it is a number.
I would like to use the numbers in col10 to make a colormap and assign ot every point a specific color that depends on the value in col10.
I did this long time ago, but I don't remember how, can somebody help me, please?
Thanks
F.

Respuesta aceptada

Star Strider
Star Strider el 5 de Ag. de 2024
I am not certain what plot you want to use or what result you want.
Perhaps something like this —
x = linspace( 0, 5);
y = linspace(-5, 5);
z = exp(-((x-2.5).^2 + y.^2));
figure
scatter3(x, y, z, 25, z, 'filled')
colormap(turbo)
colorbar
view(45,30)
x = randn(1, 1000);
y = randn(1, 1000);
z = exp(-(x.^2 + y.^2));
figure
scatter3(x, y, z, 25, z, 'filled')
colormap(turbo)
colorbar
.
  5 comentarios
Francesco
Francesco el 5 de Ag. de 2024
Thanks a lot Star Strider,
If what I wrote is ok than your example helped my memory a lot!
Cheers
Star Strider
Star Strider el 5 de Ag. de 2024
As always, my pleasure!
Thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Rahul Chowdhury
Rahul Chowdhury el 5 de Ag. de 2024
Try something like
M = [col1; col2; col10];
contourf(M, col10)
colorbar('Ticks', col10)
This creates a contour plot with the specific levels from col10 and while labeling them in a color bar. Let me know if this helps.

Categorías

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

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by