How do I get the figure position from a plot?
155 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Andreas Goser
2011-1-21
Using
get(t(1),'Position')
in your example code returns the 'Position' parameter only.
0 个评论
更多回答(1 个)
Sandy Patel
2011-1-21
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!