Is it possible to get axis size in px units if it is created in normalized units?

20 vues (au cours des 30 derniers jours)
Mr M.
Mr M. le 26 Mar 2018
Commenté : Jan le 27 Mar 2018
I have the following code: set(gcf,'units','normalized','position',[0 0 1 1]) axes('units','normalized','position',[0 0 1 1]) And I want to know axes in pixels.

Réponse acceptée

Jan
Jan le 26 Mar 2018
Modifié(e) : Jan le 26 Mar 2018
set(gcf, 'units', 'normalized', 'position', [0 0 1 1]);
AxesH = axes('units', 'normalized', 'position', [0 0 1 1]);
drawnow; % !!!!!
backUnits = get(AxesH, 'units');
set(AxesH, 'Units', 'pixels')
pixPos = get(AxesH, 'Position');
set(AxesH, 'Units', backUnits);
Without the drawnow I get my full monitor resolution, although Matlab crops the height to display the upper part of the border and the menu bar. What a pity.
A simpler method with a built-in Matlab function:
pixPos = getpixelposition(AxesH)
  1 commentaire
Jan
Jan le 27 Mar 2018

By the way: When I ask an internet search engine for "Matlab get axes position in pixels", the documentation of getpixelposition is the first hit.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by