Output positions of Matlab figures

泪湿孤枕 提交于 2020-01-04 13:08:10

问题


I want to show my graphical output of a Matlab program in a different pre-fixed window. So, that whenever I run the program, the output should be inside this figure. I followed a tutorial on the Matlab website and the created the figure as follows:

Until here everything is fine.

Now, when I what to show some output inside this figure with figure(1), Imshow(A), the figure size and position is automatically changed, which I do not want. I get something like this:

Now my question is: How do I show the outputs in the pre-calculated position and size?


回答1:


Try displaying your images with 'InitialMagnification' set to 'fit':

>> figure(1); imshow( A, 'InitialMagnification', 'fit' );

If this does not work, you might try set 'Position' of figure after showing the image.
Alternatively, you might want to consider using imagesc with axis image to display the images.




回答2:


Suggestion:

( 0. all of the figures are already created, but without the images loaded)

  1. Save the position before loading the images, eg. like: PosFig1=get(,'Position')...
  2. Load the images etc.
  3. Set the figures to there old poistions, like: set((,'Position',PosFig1)

Of course, you could put the positions into some kind of structure, to make the code to look nicer and more flexibel and so on :)



来源:https://stackoverflow.com/questions/18503494/output-positions-of-matlab-figures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!