Hi there,
I'de like to create a 2D plot with a 3rd dimension in colorscale exactly like 'imagesc' does but with a controlable y scale. When using imagesc(X,Y,Z) it sets the Y scale linear between the two ends of the Y vector ignoring everything in between.
Is there a way to do so? maybe by modifying the 'imagesc' function itself or perhaps by another function?
p.s I know that function such as 'pcolor' allows such scaling but it does not plot the same output as i require (and imagesc gives).
Thanks in advance
Y

 Respuesta aceptada

Mathieu NOE
Mathieu NOE el 9 de Nov. de 2020

0 votos

hello
this is the way I control the Z scale rendering of imagesc :
A = rand(100,100);
figure(1);imagesc(A);colorbar('vert');
% let's say we don't want to display values below "lower_limit" and above "upper_limit"
lower_limit = 0.75;
upper_limit = 0.9;
A(A<lower_limit) = lower_limit; % or NaN
A(A>upper_limit) = upper_limit; % or NaN
figure(2);imagesc(A);colorbar('vert');

5 comentarios

Yonatan Gershuni
Yonatan Gershuni el 9 de Nov. de 2020
Thank you for your answer. However my problem is not setting upper or lower limits on an axis but rather setting a costume bar. I.e say you have a y vector with values y=[1, 1.1, 1.2, 1.3, 5] (with matching x vector and z matrix). If you use imagesc(x,y,z) you will see the y axis on your image will be from 1 to 5 but in even increments.
Mathieu NOE
Mathieu NOE el 9 de Nov. de 2020
ok , so you would like imagesc to be displayed with uneven "pixels" to match the uneven spacing of x and y ?
Yonatan Gershuni
Yonatan Gershuni el 10 de Nov. de 2020
Exactly, only im not sold on imagesc so any function would do just fine if it could do it
Yonatan Gershuni
Yonatan Gershuni el 10 de Nov. de 2020
It works! Thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 9 de Nov. de 2020

Comentada:

el 10 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by