Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
Adding line/rectangle to an image in a axis on a GUI
Replies:
2
Last Post:
Oct 31, 2012 3:25 AM



Scott
Posts:
16
Registered:
10/31/12


Re: Adding line/rectangle to an image in a axis on a GUI
Posted:
Oct 31, 2012 2:01 AM


I may have found the answer by trying some different search terms in the newsreader than I had before:
as per: http://www.mathworks.com/matlabcentral/newsreader/view_thread/286314 and http://www.mathworks.com/matlabcentral/newsreader/view_thread/322516#890283
The following two alternatives seemed to work: (1) axes(myData.axis1) %alternatively set(myData.figHandle,'CurrentAxes',myData.axis1) curAxisProps=axis; hRect=rectangle(...); axis(curAxisProps)
(2) axes(myData.axis1) %alternatively set(myData.figHandle,'CurrentAxes',myData.axis1) set(gca,'xlim',xlim(gca),'ylim',ylim(gca)) hRect=rectangle(...);
So is the problem that matlab rescales an axis to fit the latest child of it? I tested this by having matlab remake the image after I made the rectangle:
axes(myData.axis1) %alternatively set(myData.figHandle,'CurrentAxes',myData.axis1) hRect=rectangle(...); axis1_Pict=imshow(myData.axis1_image,'Parent',myData.axis1)
and the picture showed up normal scale (but without the rectangle)
If anyone has better suggestions for a solution or just a better explanation of what is happening, I'd appreciate it. For now, though, (1) or (2) seem to work.



