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 个评论
Daniel Ko
Daniel Ko 2019-8-24
I am not sure what SRQ and TMW is sorry - I'm new here! Could you explain? Is it a way to contact Mathworks?
dpb
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
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

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by