x=linspace(0,2*pi,100);
y=sin(x);
h=plot(x,y);
get(h)
会显示有关plot句柄的所有相关信息。
GET(H) displays all property names and their current values for thegraphics object with handle H.
显示如下:
DisplayName: ''
Annotation: [1x1 hg.Annotation]
Color: [0 0 1]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
XData: [1x100 double]
YData: [1x100 double]
ZData: [1x0 double]
BeingDeleted: 'off'
ButtonDownFcn: []
Children: [0x1 double]
Clipping: 'on'
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'on'
HitTest: 'on'
Interruptible: 'on'
Selected: 'off'
SelectionHighlight: 'on'
Tag: ''
Type: 'line'
UIContextMenu: []
UserData: []
Visible: 'on'
Parent: 170.3105
XDataMode: 'manual'
XDataSource: ''
YDataSource: ''
ZDataSource: ''
具体每部分的意义如下:
1. DisplayName:
set(h,'DisplayName','Sin Function');
legend show
就是给这个图线起个名字,当运行legend show时,就会显示在legend上。
当绘制很多条图线时,这么做可以避免混乱。 不必在最后用legend函数一一为每条图线命名。
2. Annotation
hAnnotation= get(h,'Annotation');
hLegendEntry = get(hAnnotation','LegendInformation');
set(hLegendEntry,'IconDisplayStyle','off');
设置为off的话,该线条将不在legend里显示。
3.Color: [0 01] 线的颜色
4.LineStyle:'-' 线型
5.LineWidth: 0.5000 线宽
set(h,'Color','r','LineStyle','--','LineWidth',2.0);
6, Marker:'none'标记
7, MarkerSize:6标记大小
8, MarkerEdgeColor: 'auto' 标记的边框颜色
9, MarkerFaceColor: 'none' 标记的颜色
Marker symbol. Specifiesmarks displayed at data points. You can set values for theMarker property independently from the LineStyleproperty. Supported markers are shown in the following table.
Marker Specifier | Description |
---|---|
'+' | Plus sign |
'o' | Circle |
'*' | Asterisk |
'.' | Point |
'x' | Cross |
'square' or's' | Square |
'diamond' or'd' | Diamond |
'^' | Upward-pointing triangle |
'v' | Downward-pointing triangle |
'>' | Right-pointing triangle |
'<' | Left-pointing triangle |
'pentagram' or'p' | Five-pointed star (pentagram) |
'hexagram' or'h' | Six-pointed star (hexagram) |
'none' | No marker (default) |
set(h,'Marker','s',...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10);
10,x,y,z的数据,做动画的时候可重置这些值。
XData: [1x50 double]
YData: [1x50 double]
ZData: [1x0 double]
例子:
x=linspace(pi,2*pi,50);
y=sin(x);
set(h, 'XData',x,'YData',y);
11.BeingDeleted
on | {off} Read Only
This object is beingdeleted. The BeingDeleted property provides amechanism that you can use to determine if objects are in theprocess of being deleted. MATLAB sets the BeingDeletedproperty to on when the object's delete function callbackis called (see the DeleteFcn property). It remains set toon while the delete function executes, after which theobject no longer exists.
For example, an object's delete function might call otherfunctions that act on a number of different objects. Thesefunctions might not need to perform actions on objects if theobjects are going to be deleted, and therefore, can check theobject's BeingDeleted property before acting.
- 12.BusyAction
cancel | {queue}
Callback routineinterruption. The BusyAction property enablesyou to control how MATLAB handles events that potentially interruptexecuting callbacks. If there is a callback function executing,callbacks invoked subsequently always attempt to interrupt it.
If the Interruptible property of the object whosecallback is executing is set to on (the default), theninterruption occurs at the next point where the event queue isprocessed. If the Interruptible property is off,the BusyAction property (of the object owning theexecuting callback) determines how MATLAB handles the event. Thechoices are
- 13.ButtonDownFcn
string or function handle
Button press callbackfunction. A callback that executes whenever you press amouse button while the pointer is over this object, but not overanother graphics object. See the HitTestArea property for informationabout selecting objects of this type.
See the figure's SelectionType property to determine ifmodifier keys were also pressed.
This property can be
Set this property to a function handle that references thecallback. The expressions execute in the MATLAB workspace.
See Function Handle Callbacks for information on how to usefunction handles to define the callbacks.
- 14.Children
array of graphics object handles
Children of the barobject. The handle of a patch object that is the childof this object (whether visible or not).
If a child object's HandleVisibility property iscallback or off, its handle does not show up inthis object's Children property. If you want the handle inthe Children property, set the root ShowHiddenHandles property toon. For example:
set(0,'ShowHiddenHandles','on')
- 15.Clipping
{on} | off
Clipping mode. MATLABclips graphs to the axes plot box by default. If you setClipping to off, portions of graphs can bedisplayed outside the axes plot box. This can occur if you create aplot object, set hold to on, freeze axis scaling(axis manual), and then create a larger plotobject.
- 16.CreateFcn
string or function handle
Callback routine executed duringobject creation. This property defines a callback thatexecutes when MATLAB creates an object. You must specify thecallback during the creation of the object. For example,
graphicfcn(y,'CreateFcn',@CallbackFcn)
where @CallbackFcn is a function handlethat references the callback function andgraphicfcn is the plotting function which createsthis object.
MATLAB executes this routine after setting all other objectproperties. Setting this property on an existing object has noeffect.
The handle of the object whose CreateFcn is beingexecuted is accessible only through the rootCallbackObject property, which you can query usinggcbo.
See Function Handle Callbacks for information on how to usefunction handles to define the callback function.
- 17.DeleteFcn
string or function handle
Callback executed during objectdeletion. A callback that executes when this object isdeleted (e.g., this might happen when you issue a delete command on the object, its parent axes, or thefigure containing it). MATLAB executes the callback beforedestroying the object's properties so the callback routine canquery these values.
The handle of the object whose DeleteFcn is beingexecuted is accessible only through the root CallbackObject property, which can bequeried using gcbo.
{on} | callback | off
Control access to object's handle bycommand-line users and GUIs. This property determineswhen an object's handle is visible in its parent's list ofchildren. HandleVisibility is useful for preventingcommand-line users from accidentally accessing objects that youneed to protect for some reason.
Functions Affected by Handle Visibility
When a handle is not visible in its parent's list of children,it cannot be returned by functions that obtain handles by searchingthe object hierarchy or querying handle properties. This includesget, findobj, gca, gcf, gco, newplot, cla, clf, and close.
Properties Affected by Handle Visibility
When a handle's visibility is restricted using callbackor off, the object's handle does not appear in itsparent's Children property, figures do not appear in theroot's CurrentFigure property, objects do notappear in the root's CallbackObject property or in thefigure's CurrentObject property, and axes do notappear in their parent's CurrentAxes property.
Overriding Handle Visibility
You can set the root ShowHiddenHandles property toon to make all handles visible regardless of theirHandleVisibility settings (this does not affect the valuesof the HandleVisibility properties). See also findall.
Handle Validity
Handles that are hidden are still valid. If you know an object'shandle, you can set and get its properties and pass it to any function thatoperates on handles.
{on} | off
Selectable by mouseclick. HitTest determines whether this objectcan become the current object (as returned by the gcocommand and the figure CurrentObject property) as a resultof a mouse click on the objects that compose the area graph. IfHitTest is off, clicking this object selects theobject below it (which is usually the axes containing it).
- 20.Interruptible
{on} | off
Callback routine interruptionmode. The Interruptible property controlswhether an object's callback can be interrupted by callbacksinvoked subsequently.
Only callbacks defined for the ButtonDownFcn propertyare affected by the Interruptible property. MATLAB checksfor events that can interrupt a callback only when it encounters adrawnow, figure, getframe, or pause command in the routine. See theBusyAction property for related information.
Setting Interruptible to on allows anygraphics object's callback to interrupt callback routinesoriginating from a bar property. Note that MATLAB does not save thestate of variables or the display (e.g., the handle returned by thegca or gcf command) when an interruption occurs.
on | {off}
Is object selected? Whenyou set this property to on, MATLAB displays selection"handles" at the corners and midpoints if theSelectionHighlight property is also on (thedefault). You can, for example, define the ButtonDownFcncallback to set this property to on, thereby indicatingthat this particular object is selected. This property is also setto on when an object is manually selected in plot editmode.
- 22. SelectionHighlight
{on} | off
Objects are highlighted whenselected. When the Selected property ison, MATLAB indicates the selected state by drawing fouredge handles and four corner handles. WhenSelectionHighlight is off, MATLAB does not drawthe handles except when in plot edit mode and objects are selectedmanually.
- 23.Tag
string
User-specified objectlabel. The Tag property provides a means toidentify graphics objects with a user-specified label. This isparticularly useful when you are constructing interactive graphicsprograms that would otherwise need to define object handles asglobal variables or pass them as arguments between callbacks. Youcan define Tag as any string.
For example, you might create an areaseries object and set theTag property.
t = area(Y,'Tag','area1')
When you want to access objects of a given type, you can usefindobj to find the object's handle. The followingstatement changes the FaceColor property of the objectwhose Tag is area1.
set(findobj('Tag','area1'),'FaceColor','red')
- 24.Type
string (read only)
Type of graphics object.This property contains a string that identifies the class of thegraphics object. For areaseries objects, Type is'hggroup'.
The following statement finds all the hggroup objects in thecurrent axes.
t = findobj(gca,'Type','hggroup');
- 25.UIContextMenu
handle of a uicontextmenu object
Associate a context menu with thisobject. Assign this property the handle of auicontextmenu object created in the object's parent figure. Use theuicontextmenu function to create the context menu.MATLAB displays the context menu whenever you right-click over theobject.
- 26.UserData
array
User-specified data. Thisproperty can be any data you want to associate with this object(including cell arrays and structures). The object does not setvalues for this property, but you can access it using the set and get functions.
- 27.Visible
{on} | off
Visibility of this object and itschildren. By default, a new object's visibility ison. This means all children of the object are visibleunless the child object's Visible property is set tooff. Setting an object's Visible property tooff prevents the object from being displayed. However, theobject still exists and you can set and query its properties.
- 28.XDataMode
{auto} | manual
Use automatic or user-specifiedx-axis values. If you specify XData (bysetting the XData property or specifying the xinput argument), MATLAB sets this property to manual anduses the specified values to label the x-axis.
If you set XDataMode to auto after havingspecified XData, MATLAB resets the x-axis ticks to 1:size(YData,1)or to the column indices of the ZData, overwriting anyprevious values for XData.
- 29.XDataSource
string (MATLAB variable)
LinkXData to MATLABvariable. Set this property to a MATLAB variable thatis evaluated in the base workspace to generate theXData.
MATLAB reevaluates this property only when you set it.Therefore, a change to workspace variables appearing in anexpression does not change XData.
You can use the refreshdata function to force an updateof the object's data. refreshdata also enables you tospecify that the data source variable be evaluated in the workspaceof a function from which you call refreshdata.
- 30.YDataSource
string (MATLAB variable)
LinkYData to MATLABvariable. Set this property to a MATLAB variable thatis evaluated in the base workspace to generate theYData.
MATLAB reevaluates this property only when you set it.Therefore, a change to workspace variables appearing in anexpression does not change YData.
You can use the refreshdata function to force an updateof the object's data. refreshdata also enables you tospecify that the data source variable be evaluated in the workspaceof a function from which you call refreshdata.
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html