加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Matlab plot函数详解

(2010-07-06 17:45:57)
标签:

matlab

plot

函数详解

分类: matlab
运行下列命令,
x=linspace(0,2*pi,100);
y=sin(x);
h=plot(x,y);
http://s8/bmiddle/618af195g8ab4fbd224f7&690plot函数详解" TITLE="Matlab plot函数详解" />

get(h)
会显示有关plot句柄的所有相关信息。
GET(H) displays all property names and their current values for the graphics 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上。
http://s13/bmiddle/618af195g8ab4ff0665fc&690plot函数详解" TITLE="Matlab plot函数详解" />
当绘制很多条图线时,这么做可以避免混乱。 不必在最后用legend函数一一为每条图线命名。
2. Annotation
hAnnotation = get(h,'Annotation');
hLegendEntry = get(hAnnotation','LegendInformation');
set(hLegendEntry,'IconDisplayStyle','off');
设置为off的话,该线条将不在legend里显示。

3.Color: [0 0 1]    线的颜色
4.LineStyle: '-'    线型
5.LineWidth: 0.5000 线宽

set(h,'Color','r','LineStyle','--','LineWidth',2.0);
http://s11/bmiddle/618af195g8ab5407d724a&690plot函数详解" TITLE="Matlab plot函数详解" />

6, Marker: 'none'     标记
7, MarkerSize: 6      标记大小
8, MarkerEdgeColor: 'auto'  标记的边框颜色
9, MarkerFaceColor: 'none'  标记的颜色

Marker symbol. Specifies marks displayed at data points. You can set values for the Marker property independently from the LineStyle property. 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);           http://s2/bmiddle/618af195g8ab551daa391&690plot函数详解" TITLE="Matlab plot函数详解" />

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);
http://s3/bmiddle/618af195g8ab60fcc1ec2&690plot函数详解" TITLE="Matlab plot函数详解" />
11.BeingDeleted

on | {off} Read Only

This object is being deleted. The BeingDeleted property provides a mechanism that you can use to determine if objects are in the process of being deleted. MATLAB sets the BeingDeleted property to on when the object's delete function callback is called (see the DeleteFcn property). It remains set to on while the delete function executes, after which the object no longer exists.

For example, an object's delete function might call other functions that act on a number of different objects. These functions might not need to perform actions on objects if the objects are going to be deleted, and therefore, can check the object's BeingDeleted property before acting.

12. BusyAction

cancel | {queue}

Callback routine interruption. The BusyAction property enables you to control how MATLAB handles events that potentially interrupt executing callbacks. If there is a callback function executing, callbacks invoked subsequently always attempt to interrupt it.

If the Interruptible property of the object whose callback is executing is set to on (the default), then interruption occurs at the next point where the event queue is processed. If the Interruptible property is off, the BusyAction property (of the object owning the executing callback) determines how MATLAB handles the event. The choices are

  • cancel — Discard the event that attempted to execute a second callback routine.

  • queue — Queue the event that attempted to execute a second callback routine until the current callback finishes.

13. ButtonDownFcn

string or function handle

Button press callback function. A callback that executes whenever you press a mouse button while the pointer is over this object, but not over another graphics object. See the HitTestArea property for information about selecting objects of this type.

See the figure's SelectionType property to determine if modifier keys were also pressed.

This property can be

  • A string that is a valid MATLAB expression

  • The name of a MATLAB file

  • A function handle

Set this property to a function handle that references the callback. The expressions execute in the MATLAB workspace.

See Function Handle Callbacks for information on how to use function handles to define the callbacks.

14. Children

array of graphics object handles

Children of the bar object. The handle of a patch object that is the child of this object (whether visible or not).

If a child object's HandleVisibility property is callback or off, its handle does not show up in this object's Children property. If you want the handle in the Children property, set the root ShowHiddenHandles property to on. For example:

set(0,'ShowHiddenHandles','on')
15. Clipping

{on} | off

Clipping mode. MATLAB clips graphs to the axes plot box by default. If you set Clipping to off, portions of graphs can be displayed outside the axes plot box. This can occur if you create a plot object, set hold to on, freeze axis scaling (axis manual), and then create a larger plot object.

16.CreateFcn

string or function handle

Callback routine executed during object creation. This property defines a callback that executes when MATLAB creates an object. You must specify the callback during the creation of the object. For example,

graphicfcn(y,'CreateFcn',@CallbackFcn)

where @CallbackFcn is a function handle that references the callback function and graphicfcn is the plotting function which creates this object.

MATLAB executes this routine after setting all other object properties. Setting this property on an existing object has no effect.

The handle of the object whose CreateFcn is being executed is accessible only through the root CallbackObject property, which you can query using gcbo.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

17. DeleteFcn

string or function handle

Callback executed during object deletion. A callback that executes when this object is deleted (e.g., this might happen when you issue a delete command on the object, its parent axes, or the figure containing it). MATLAB executes the callback before destroying the object's properties so the callback routine can query these values.

The handle of the object whose DeleteFcn is being executed is accessible only through the root CallbackObject property, which can be queried using gcbo.

18.HandleVisibility

{on} | callback | off

Control access to object's handle by command-line users and GUIs. This property determines when an object's handle is visible in its parent's list of children. HandleVisibility is useful for preventing command-line users from accidentally accessing objects that you need to protect for some reason.

  • on — Handles are always visible when HandleVisibility is on.

  • callback — Setting HandleVisibility to callback causes handles to be visible from within callback routines or functions invoked by callback routines, but not from within functions invoked from the command line. This provides a means to protect GUIs from command-line users, while allowing callback routines to have access to object handles.

  • off — Setting HandleVisibility to off makes handles invisible at all times. This might be necessary when a callback invokes a function that might potentially damage the GUI (such as evaluating a user-typed string) and so temporarily hides its own handles during the execution of that function.

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 searching the object hierarchy or querying handle properties. This includes get, findobj, gca, gcf, gco, newplot, cla, clf, and close.

Properties Affected by Handle Visibility

When a handle's visibility is restricted using callback or off, the object's handle does not appear in its parent's Children property, figures do not appear in the root's CurrentFigure property, objects do not appear in the root's CallbackObject property or in the figure's CurrentObject property, and axes do not appear in their parent's CurrentAxes property.

Overriding Handle Visibility

You can set the root ShowHiddenHandles property to on to make all handles visible regardless of their HandleVisibility settings (this does not affect the values of the HandleVisibility properties). See also findall.

Handle Validity

Handles that are hidden are still valid. If you know an object's handle, you can set and get its properties and pass it to any function that operates on handles.

19.HitTest

{on} | off

Selectable by mouse click. HitTest determines whether this object can become the current object (as returned by the gco command and the figure CurrentObject property) as a result of a mouse click on the objects that compose the area graph. If HitTest is off, clicking this object selects the object below it (which is usually the axes containing it).

20. Interruptible

{on} | off

Callback routine interruption mode. The Interruptible property controls whether an object's callback can be interrupted by callbacks invoked subsequently.

Only callbacks defined for the ButtonDownFcn property are affected by the Interruptible property. MATLAB checks for events that can interrupt a callback only when it encounters a drawnow, figure, getframe, or pause command in the routine. See the BusyAction property for related information.

Setting Interruptible to on allows any graphics object's callback to interrupt callback routines originating from a bar property. Note that MATLAB does not save the state of variables or the display (e.g., the handle returned by the gca or gcf command) when an interruption occurs.

21.Selected

on | {off}

Is object selected? When you set this property to on, MATLAB displays selection "handles" at the corners and midpoints if the SelectionHighlight property is also on (the default). You can, for example, define the ButtonDownFcn callback to set this property to on, thereby indicating that this particular object is selected. This property is also set to on when an object is manually selected in plot edit mode.

22. SelectionHighlight

{on} | off

Objects are highlighted when selected. When the Selected property is on, MATLAB indicates the selected state by drawing four edge handles and four corner handles. When SelectionHighlight is off, MATLAB does not draw the handles except when in plot edit mode and objects are selected manually.

23. Tag

string

User-specified object label. The Tag property provides a means to identify graphics objects with a user-specified label. This is particularly useful when you are constructing interactive graphics programs that would otherwise need to define object handles as global variables or pass them as arguments between callbacks. You can define Tag as any string.

For example, you might create an areaseries object and set the Tag property.

t = area(Y,'Tag','area1')

When you want to access objects of a given type, you can use findobj to find the object's handle. The following statement changes the FaceColor property of the object whose 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 the graphics object. For areaseries objects, Type is 'hggroup'.

The following statement finds all the hggroup objects in the current axes.

t = findobj(gca,'Type','hggroup');
25. UIContextMenu

handle of a uicontextmenu object

Associate a context menu with this object. Assign this property the handle of a uicontextmenu object created in the object's parent figure. Use the uicontextmenu function to create the context menu. MATLAB displays the context menu whenever you right-click over the object.

26. UserData

array

User-specified data. This property can be any data you want to associate with this object (including cell arrays and structures). The object does not set values for this property, but you can access it using the set and get functions.

27. Visible

{on} | off

Visibility of this object and its children. By default, a new object's visibility is on. This means all children of the object are visible unless the child object's Visible property is set to off. Setting an object's Visible property to off prevents the object from being displayed. However, the object still exists and you can set and query its properties.

28. XDataMode

{auto} | manual

Use automatic or user-specified x-axis values. If you specify XData (by setting the XData property or specifying the x input argument), MATLAB sets this property to manual and uses the specified values to label the x-axis.

If you set XDataMode to auto after having specified XData, MATLAB resets the x-axis ticks to 1:size(YData,1) or to the column indices of the ZData, overwriting any previous values for XData.

29. XDataSource

string (MATLAB variable)

Link XData to MATLAB variable. Set this property to a MATLAB variable that is evaluated in the base workspace to generate the XData.

MATLAB reevaluates this property only when you set it. Therefore, a change to workspace variables appearing in an expression does not change XData.

You can use the refreshdata function to force an update of the object's data. refreshdata also enables you to specify that the data source variable be evaluated in the workspace of a function from which you call refreshdata.

30. YDataSource

string (MATLAB variable)

Link YData to MATLAB variable. Set this property to a MATLAB variable that is evaluated in the base workspace to generate the YData.

MATLAB reevaluates this property only when you set it. Therefore, a change to workspace variables appearing in an expression does not change YData.

You can use the refreshdata function to force an update of the object's data. refreshdata also enables you to specify that the data source variable be evaluated in the workspace of a function from which you call refreshdata.

英文部分链接:http://www.mathworks.com/access/helpdesk/help/techdoc/ref/areaseriesproperties.html
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有