Stop Displayed Image in UI Figure from being Moved by User

2 ビュー (過去 30 日間)
crawler
crawler 2019 年 2 月 22 日
編集済み: crawler 2019 年 3 月 14 日
Hi,
I have this piece of code to display a logo on a UI Axes that ives in a UI figure
Although it plots well, the image isnt fixed, and the user can simply move it about with the mouse.
How can I prevent this.
%display logo on axes
matlabImage = imread('Images\Logo.png'); %read image file
image(app.UIAxes,matlabImage); %plot image in UIAxes component
app.UIAxes.Visible = false; %make axes invisible
Thanks

回答 (1 件)

Geoff Hayes
Geoff Hayes 2019 年 3 月 10 日
Shakirudeen - actually, imshow does allow you to specify the axes to plot the image to
'Parent' — Parent axes of image object
axes object
Parent axes of image object, specified as the comma-separated pair consisting of 'Parent' and an axes object. Use the 'Parent' name-value argument to build a UI that gives you control of the figure and axes properties.
So you would do something like
imshow(myImage, 'Parent', axesHandle);
where axesHandle is the handle to the axes where you want the image to appear.
  1 件のコメント
crawler
crawler 2019 年 3 月 14 日
@Geoff Hayes, many thanks for your answer.
Yes you are right, I always seem to forget about the 'Parent' property.
However, after playing with it, I realised that my earlier presumption that 'imshow' works was actually wrong, as it basicaly behaves the same was as using 'image'.
I realised that the problem of the image being movable only occurs when the parent figure is a 'UIFigure'. Otherwise it works alright when using 'Figure', either using 'image' or 'imshow'.
That said, I would prefer not to switch to using 'Figure' so the problem still remains. I'll edit my question to reflect this.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by