How to set images to fill the axes?

I am trying to make it so that the all the images I show in an axes fill the axes completely, no matter the size of the image.

 Respuesta aceptada

Star Strider
Star Strider el 25 de Ag. de 2014
Use:
axis image
See the documentation for axis for details.

12 comentarios

Giann Geocadin
Giann Geocadin el 25 de Ag. de 2014
how do I implement axis image and should I just switch the name from axes to axis?
Put the ‘axis image’ call just after you create the figure window:
ppr = imread('peppers.png');
figure(1)
imshow(ppr)
axis image
Giann Geocadin
Giann Geocadin el 25 de Ag. de 2014
if i'm not using a figure, would I just implement it after the imshow ('image')
Star Strider
Star Strider el 25 de Ag. de 2014
Yes. I do figure for each one out of habit because then I don’t overwrite an existing figure, but it is not necessary.
Giann Geocadin
Giann Geocadin el 25 de Ag. de 2014
Ok so the width of the images isn't changing, however the height of the images is still moving even with the axis image implemented after every image.
You can set the height and width for all of them to be the same by adding 'XData' and 'YData' to the imshow call:
imshow(ppr, 'XData',[1 315], 'YData',[1 400]);
Experiment with those values until you get the result you want. Note that changing the aspect ratio with these will distort the displayed image.
Giann Geocadin
Giann Geocadin el 25 de Ag. de 2014
a distorted image is fine, thanks for the help
Star Strider
Star Strider el 25 de Ag. de 2014
My pleasure!
Stelios Fanourakis
Stelios Fanourakis el 23 de Mayo de 2018
@Star Strider. Thanks a lot Star Strider. Your comment was very helpful
Jan
Jan el 23 de Mayo de 2018
[MOVED from flags] Stelios Fanourakis wrote:
Very nice. It worked to me. Thanks
@Stelios: Please use flags only to inform admins and editors about inappropriate content, like spam or rudeness. Thanks.
Star Strider
Star Strider el 23 de Mayo de 2018
@Stelios — My pleasure.
@Jan — Thank you.
Ahmer Shahid
Ahmer Shahid el 13 de En. de 2019
How can I use this in app desginer?
can I use this for specific axes?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Preguntada:

el 25 de Ag. de 2014

Comentada:

el 13 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by