How do I get the figure position from a plot?

192 vues (au cours des 30 derniers jours)
mahmud mohammadi
mahmud mohammadi le 21 Jan 2011
I create a 3D contour plot like this:
[C,h]=contour3(w,p,green1,30);
t=clabel(C,h);
get(t(1));
This created a 3D plot and this output:
Annotation = [ (1 by 1) hg.Annotation array]
BackgroundColor = none
Color = [0 0 0]
DisplayName =
EdgeColor = none
Editing = off
Extent = [ (1 by 4) double array]
FontAngle = normal
FontName = Helvetica
FontSize = [10]
FontUnits = points
FontWeight = normal
HorizontalAlignment = center
LineStyle = -
LineWidth = [0.5]
Margin = [2]
Position = [-0.661507 0.649385 -0.01794]
Rotation = [290.824]
String = -0.01794
Units = data
Interpreter = tex
VerticalAlignment = middle
BeingDeleted = off
ButtonDownFcn =
Children = []
Clipping = on
CreateFcn =
DeleteFcn =
BusyAction = queue
HandleVisibility = on
HitTest = on
Interruptible = on
Parent = [170.001]
Selected = off
SelectionHighlight = on
Tag =
Type = text
UIContextMenu = []
UserData = [-0.01794]
Visible = on
I want to save matrix 'Position'. How do I do that?
  1 commentaire
Andreas Goser
Andreas Goser le 21 Jan 2011
Reformating the code would help to understand and reproduce

Connectez-vous pour commenter.

Réponse acceptée

Andreas Goser
Andreas Goser le 21 Jan 2011
Using
get(t(1),'Position')
in your example code returns the 'Position' parameter only.

Plus de réponses (1)

Sandy Patel
Sandy Patel le 21 Jan 2011
I wanted to expand a little on that answer from Andreas. You had asked in the title for the position of the figure: You would actually want to do
get(h,'Position')
to get the Position of the figure on the screen.
To get the position(s) of the contour labels of the first contour you would do what Andreas posted:
get(t(1),'Position')
Bear in mind this will return an x,y,z position for each label on that contour (it could appear more than one time).
Something I just wanted to add: I often find I do not conveniently have the handle of an object so I often get a property by making it the current object and then getting the property I desire. For example:
get(gcf,'Position') % get the position of the current figure
get(gca,'Position') % get the position of the current axis
Finally, remember down the road that (generally speaking) you can 'get' nearly every property of an object (figure, axes, lines, labels, etc.) described in the Matlab help, so there is a lot of usefulness in the knowing this command. Learn the 'set' command and you will a lot more power in controlling objects in Matlab.
Cheers, Sandy

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by