How do I get the figure position from a plot?

156 Ansichten (letzte 30 Tage)
mahmud mohammadi
mahmud mohammadi am 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 Kommentar
Andreas Goser
Andreas Goser am 21 Jan. 2011
Reformating the code would help to understand and reproduce

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (1)

Sandy Patel
Sandy Patel am 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

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by