Aligning axes of different sizes within a GUI

Hello,
I have a trivial question but not able find a effective solution. I hope somebody could help me in this regard.
I currently have 4 different axes in a GUI. ax1(top left) and ax4(bottom left) should be aligned vertically and similarly ax2(top right) and ax4(bottom right) should be aligned vertically. (I have attached a sample image)
ax1 and ax2 are used to show images that are usually larger in size(~512x512) and ax3 & ax4 are used to display images of size ~43x512. Even though I created the axes with x-axis the same size when I display images they change size and not aligned anymore. No matter what images I display, I want the top and bottom images to of same x length and aligned always.
I tried to keep the XLim the same; XData the same but still doesnt work.
Any help is greatly appreciated.
Thanks, Bala

5 comentarios

Adam
Adam el 10 de Feb. de 2015
I just did a quick test creating axes and plotting images of the size you said from command line and it seemed to work fine, but obviously that does not replicate exactly what you did, starting in guide, but there may be something you are setting that is causing this.
Are you changing the PlotBoxAspectRatio or the DataAspectRatio of either pair of plots?
Bala
Bala el 10 de Feb. de 2015
Thanks for your quick reply.
Nope. I'm not changing those ratios. Both are set to [1 1 1] and set to auto. Do I need to change any of these?
Adam
Adam el 10 de Feb. de 2015
You shouldn't need to. My plots where the axes lined up were without changing those, but when I did manually change them then I got images of different sizes.
You get this behaviour, annoyingly, when you put a colourbar on an axes as this takes space out of the axes, but in your case you have no colourbar so it isn't immediately obvious to me why your images should be different sizes.
How are you plotting your images?
I always use imagesc or image which stretch the image to fill the size of the axes. I think imshow will resize the axes to match the ratio of the image though so you may well need to play around with the following properties of one or other pair of axes:
Position
PlotBoxAspectRatio
DataAspectRatio
Bala
Bala el 11 de Feb. de 2015
Hi Adam,
I use imshow to display images. (i.e. hI = imshow(im,[int1 int2])) You are right. Imshow is resizing the axes to match the im size. I played around with Positon property but didnt help much. I will look into other two but any quick hints might be helpful.
Thanks again!

Iniciar sesión para comentar.

Respuestas (1)

Sumit Tandon
Sumit Tandon el 10 de Feb. de 2015

0 votos

Check out the ALIGN function. Calling this function after the axes have been populated with the images should do the trick.

1 comentario

Bala
Bala el 11 de Feb. de 2015
Hi Sumit,
Thanks for your reply. But Align is just not what I need. Looks like I need something to resize to match the axes above. I think what I found is, if the size of the image is different from the axes size, the image resizes automatically and hence not the same size as axes when displayed. So I guess I need something(a command or property) that will fill the axes when displayed.
thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Feb. de 2015

Comentada:

el 11 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by