Why won't my axes position change stick?

9 visualizaciones (últimos 30 días)
Daniel Ko
Daniel Ko el 24 de Ag. de 2019
Respondida: Asvin Kumar el 28 de Ag. de 2019
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 comentarios
Daniel Ko
Daniel Ko el 24 de Ag. de 2019
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 el 24 de Ag. de 2019
TMW--The MathWorks and SRQ--> Service Request. There is a "contact us" link at the top (the telephone receiver icon) you can use.

Iniciar sesión para comentar.

Respuestas (1)

Asvin Kumar
Asvin Kumar el 28 de Ag. de 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

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by