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?
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2019-8-24
TMW--The MathWorks and SRQ--> Service Request. There is a "contact us" link at the top (the telephone receiver icon) you can use.
回答(1 个)
Asvin Kumar
2019-8-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!