Solved! It turns out putting a short pause (pause(0.01)) between my Position assignments fixes this? I am not sure why however.
Why won't my axes position change stick?
5 views (last 30 days)
Show older comments
Hello,
I am trying to copyobj a heatmap (imagesc in an axes with a colorbar) into another figure and then reposition them, byt my position declarations seem to fail with no errors - can I have some insight as to how to solve this please?
f is a figure with just the heatmap and a colorbar, f.Children(2) being the axes and f.Children(1) being the colorbar. My f.Children(2).Position does not seem to stick. I tried using set(). Also, this does not seem to happen when I move the colorbar and the re-positioning works when I go step by step using the debugger, but not when I just run the script.
K>> f.Children(2)
ans =
Axes with properties:
XLim: [-90 90]
YLim: [-90 90]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0 0 0.9511 1.0000]
Units: 'normalized'
Show all properties
K>> [left, bottom, xFigS, yFigS]
ans =
0.0500 0.1000 0.4250 0.8000
K>> f.Children(2).Position = [left, bottom, xFigS, yFigS]
f =
Figure (1) with properties:
Number: 1
Name: ''
Color: [0.9400 0.9400 0.9400]
Position: [618 155 1200 800]
Units: 'pixels'
Show all properties
K>> f.Children(2).Position
ans =
0 0 0.9511 1.0000
4 Comments
dpb
on 24 Aug 2019
TMW--The MathWorks and SRQ--> Service Request. There is a "contact us" link at the top (the telephone receiver icon) you can use.
Answers (1)
Asvin Kumar
on 28 Aug 2019
Use the drawnow command while setting or getting positions of any graphics objects. This makes sure that things are in sync as the two are running on different threads.
For best practice, use drawnow before asking for position of any object because it forces previous updates that haven’t reflected yet.
Here’s the documentation for more information: https://www.mathworks.com/help/matlab/ref/drawnow.html
0 Comments
See Also
Categories
Find more on Orange in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!