MATLAB绘图概述

来源:互联网 发布:网络数据挖掘 编辑:程序博客网 时间:2024/05/16 10:06

MATLAB点图的概述

MATLAB提供一个技术性的宽度变量来显示结构式的数据。交互式工具使你操纵图形到获取揭露你的数据更多信息的结果。你也能够注释和打印图形,显示到屏幕上。或者导出图形到标准图形。

更多信息:请访问帮助浏览器

一、点图处理

典型显像数据的过程涉及一系列操作。这部分提供一个“大照片”点图处理的查看和含有链接到有例子和特殊详细关于执行每个操作的部分。

1.创建一个图形

你选择去创建的图表的类型,凭借你的数据的性质和你想要显示关于什么数据。MATLAB提供定义很多图形类型,例如行,条,histogram和饼图。那也有3D图形。例如表面,slice planes和streamlines。

在MATLAB中有两种创建图形的基本方式

(1)使用点图工具交互式创建图形

查看例子--使用MATLAB点图工具

(2)在命令窗口中使用命令行交互式输入命令或创建点图程序。

查看基础点图函数

你可以查找它有利于结合两种方式。例如,你可以发布一个点图命令去创建一个图形然后使用交互式工具的一种修改图形。

2.导出数据

一旦你创建一个图形,你能够提取关于数据的特殊信息,例如一个高峰点的数值,一个数据系列的平均值,或你能执行数据装置。

更多信息:在MATLAB文档中查看数据探究工具。

3.编辑图像部件

图形对象的构成,其有你能够改变的属性。属性影响各种图表部件查看和运行的方式。

例如,axes被用于定义调整图表系统有属性定义限制每个轴,尺寸,颜色,等等。线被用于创建一行有属性的图表,例如颜色,被使用的标记的类型在每个数据点(如果任何),行风格,等等。

注意:数据被用于创建一行图表是行的属性。你能够,因此,改变数据其实没有创建一个新图形。

查看编辑点图。

4.注释图表

注释是文本,箭头,调用外部,和其他标签添加到图形用来帮助查看者查看这对于数据是多么的重要。当你想要展示它们给其他人或当你想要保存它们为以后的参考时,你典型的添加注释到图形。

更多信息:在MATLAB文档中或选择注释图标从图片帮助菜单中查阅注释图标

5.打印和导出图形

你能够打印你的图表在任何连通到你的电脑上的打印机。页面设置对话让你控制大小,布局,和其他图表的属性(从图片文件菜单中选择页面设置)

导出一个图表菜单创建一个它在标准图形文件格式中的拷贝,例如TIF,JPEG或EPS。你能够然后输入文件到一个词处理器,包括它在一个HTML文档中,或编辑它在一个绘图包中(从图片文件菜单中选择导出设置)。

更多信息:查看打印命令参考页面和在MATLAB文档中打印并导出或从图片帮助菜单中选择打印和导出。

6.保存图形到再次加载到MATLAB

那里有保存图形的两种方式,在它们的准备中确定你保存工作。

(1)保存图形作为一个FIG文件(从图片文件菜单中选择保存)

(2)一般MATLAB代码,能够再次创建图形(从图片文件菜单中选择一般M文件)

FIG文件:FIG文件是一个二进制格式,在它的通用状态中保存一个图片。这各意味着所有图形对象和属性设置当你创建它时是被存储在文件中。

注意:任何图形工具的状态(i.e,任何在工具条中的项目)不是被保存在一个FIG文件中,仅图形的目录是被保存的。

一般代码。你能够使用MATLAB M代码发生器去创建再次创建图表的代码。不像一个FIG文件,一般代码不会含有任何数据。当你运行代码的时候,你必须通过数据去产生函数

注意:研究为图表生成代码是一个学习如何用MATLAB写程序的好的方式

更多信息:查看打印命令参考页面和在MATLAB文档中保存你的工作

二、图表部件

MATLAB显示图表在一个特殊的窗口中。创建一个图表,你需要定义一个调整系统。所以每个图表是带有轴的被图片含有的地方。

现实数据的视觉表示是获取像行和表面的图形对象。这些对象是绘制在调整系统里面被axes定义的。MATLAB自动创建细节到供给数据的范围。现实数据是被存储为图形对象程序。

查看处理图形更多关于图形对象程序的信息

下面图片展示了一个典型图表的基础部件

 

三、图片工具

图片是被配置为在图形上操作工具的设置。图片工具菜单提供存取许多图片工具。

更多信息:在MATLAB文档中查看MATLAB点图工具或从图片帮助菜单中选择点图工具

1.存取到工具

你能够从查看菜单中存取图片工具条和点图工具,作为在下面图片中的展示。

2.图片工具

图片工具条提供简单存取到许过图表修改属性。那有三各工具条。当你光标覆盖一个细节工具的地方,一个文本盒子显示工具的名称。以下图片展示了三个工具条。

更多信息:在MATLAB文档中查看图片工具条。

3.点图工具

点图工具是附加到图片和为创建图表创建一个环境。这里的工具确定你去做以下:

(1)从一个图表类型的宽变量选择

(2)设置图表对象的代码

(3)注释图表,文本,箭头,等等。

(4)在图片中创建和排列附属点

(5)拖拽数据到图表

从查看菜单中或在图片工具条中通过点击显示点图工具,在下面图片中展示:

那是三个部件到点工具:

(1)图片调色板--指定和安排附属点,为点图或编辑存取工作空间变量,并添加附注。

(2)点浏览器--在图形层次中选择对象,控制能见度,和添加数据到axes。

(3)特性编辑器--改变被选择对象的关键属性。为存取到所有对象属性点击检查。

以下图片展示一个图片带有点图工具。

4.点图工具和MATLAB命令

你能够确认在任何图表上的点图工具,,甚至如果你使用MATLAB命令创建它。例如,假设你创建以下图表。

t = 0:pi/20:2*pi;
y = exp(sin(t));
plotyy(t,y,t,y,'plot','stem')
xlabel('X Axis')
ylabel('Plot Y Axis')
title('Two Y Axes')

这个图表包含两个y轴,一个为每个点的类型(线和径图表)。点图工具是它简单去选择图表包含的对象的任何和设置它的属性。

例如,为y轴添加一个标签,其相当于在点浏览器中把点通过选择轴简单的实行和在属性编辑器中设置Y标签属性。

四、在图像里面排列一个图表

下面图像展示了如何在图片中指定四个2D轴。

选择轴你想要的点的目标。你也能使用穿插命令去创建多种轴。

五、选择点类型

你能使用点目录为点数据选择从一个技术性的变量。存取点目录。

1.在图片调色板中选择你想要的点的变量。

2.右键单击显示条件菜单。

3.选择更多点去显示目录。

一旦你选择了一个点类型,MATLAB显示带有选定变量的点目录读取到点。

 

Overview of MATLAB Plotting

MATLAB provides a wide variety of techniques to display data graphically. Interactive tools enable you to manipulate graphs to achieve results that reveal the most information about your data. You can also annotate and print graphs for presentations, or export graphs to standard graphics formats for presentation in web browsers or other media.

For More Information    Graphics and 3-D Visualization in the MATLAB documentation provide in-depth coverage of MATLAB graphics and visualization tools. Access these topics from the Help browser.

一、The Plotting Process

The process of visualizing data typically involves a series of operations. This section provides a "big picture" view of the plotting process and contains links to sections that have examples and specific details about performing each operation.

1.Creating a Graph

The type of graph you choose to create depends on the nature of your data and what you want to reveal about the data. MATLAB predefines many graph types, such as line, bar, histogram, and pie graphs. There are also 3-D graphs, such as surfaces, slice planes, and streamlines.

There are two basic ways to create graphs in MATLAB:

(1)Use plotting tools to create graphs interactively.

See Examples -- Using MATLAB Plotting Tools.

(2)Use the command interface to enter commands in the Command Window or create plotting programs.

See Basic Plotting Functions.

You might find it useful to combine both approaches. For example, you might issue a plotting command to create a graph and then modify the graph using one of the interactive tools.

2.Exploring Data

Once you create a graph, you can extract specific information about the data, such as the numeric value of a peak in a plot, the average value of a series of data, or you can perform data fitting.

For More Information    See Data Exploration Tools in the MATLAB documentation.

3.Editing the Graph Components

Graphs are composed of objects, which have properties you can change. These properties affect the way the various graph components look and behave.

For example, the axes used to define the coordinate system of the graph has properties that define the limits of each axis, the scale, color, etc. The line used to create a line graph has properties such as color, type of marker used at each data point (if any), line style, etc.

Note that the data used to create a line graph are properties of the line. You can, therefore, change the data without actually creating a new graph.

See Editing Plots.

4.Annotating Graphs

Annotations are the text, arrows, callouts, and other labels added to graphs to help viewers see what is important about the data. You typically add annotations to graphs when you want to show them to other people or when you want to save them for later reference.

For More Information    See Annotating Graphs in the MATLAB documentation or select Annotating Graphs from the figure Help menu.

5.Printing and Exporting Graphs

You can print your graph on any printer connected to your computer. The print previewer enables you to view how your graph will look when printed. It enables you to add headers, footers, a date, and so on. The page setup dialog lets you control the size, layout, and other characteristics of the graph (select Page Setup from the figure File menu).

Exporting a graph means creating a copy of it in a standard graphics file format, such as TIF, JPEG, or EPS. You can then import the file into a word processor, include it in an HTML document, or edit it in a drawing package select Export Setup from the figure File menu).

For More Information    See the print command reference page and Printing and Exporting in the MATLAB documentation or select Printing and Exporting from the figure Help menu.

6.Saving Graphs to Reload into MATLAB

There are two ways to save graphs that enable you to save the work you have invested in their preparation:

(1)Save the graph as a FIG-file (select Save from the figure File menu).

(2)Generate MATLAB code that can recreate the graph (select Generate M-File from the figure File menu).

FIG-Files.   FIG-files are a binary format that saves a figure in its current state. This means that all graphics objects and property settings are stored in the file when you create it. You can reload the file into a different MATLAB session, even if you are running MATLAB on a different type of computer. When you load a FIG-file, MATLAB creates a new figure in the same state as the one you saved.

Note that the states of any figure tools (i.e., any items on the toolbars) are not saved in a FIG-file; only the contents of the graph are saved.

Generated Code.   You can use the MATLAB M-code generator to create code that recreates the graph. Unlike a FIG-file, the generated code does not contain any data. You must pass the data to the generated function when you run the code.

Note that studying the generating code for a graph is a good way to learn how to program with MATLAB.

For More Information    See the print command reference page and Saving Your Work in the MATLAB documentation.

二、Graph Components

MATLAB displays graphs in a special window known as a figure. To create a graph, you need to define a coordinate system. Therefore every graph is placed within axes, which are contained by the figure.

The actual visual representation of the data is achieved with graphics objects like lines and surfaces. These objects are drawn within the coordinate system defined by the axes, which MATLAB automatically creates specifically to accommodate the range of the data. The actual data is stored as properties of the graphics objects.

See Handle Graphics for more information about graphics object properties.

The following picture shows the basic components of a typical graph.

三、Figure Tools

The figure is equipped with sets of tools that operate on graphs. The figure Tools menu provides access to many graph tools.

For More Information    See MATLAB Plotting Tools in the MATLAB documentation or select Plotting Tools from the figure Help menu.

1.Access to Tools

You can access the figure toolbars and the plotting tools from the View menu, as shown in the following picture.

2.Figure Toolbars

Figure toolbars provide easy access to many graph modification features. There are three toolbars. When you place the cursor over a particular tool, a text box pops up with the tool name. The following picture shows the three toolbars displayed with the cursor over the Data Cursor tool.

For More Information    See Figure Toolbars in the MATLAB documentation.

3.Plotting Tools

Plotting tools are attached to figures and create an environment for creating graphs. These tools enable you to do the following:

(1)Select from a wide variety of graph types

(2)Set the properties of graphics objects

(3)Annotate graphs with text, arrows, etc.

(4)Create and arrange subplots in the figure

(5)Drag and drop data into graphs

Display the plotting tools from the View menu or by clicking in the figure toolbar, as shown in the following picture.

There are three components to the plotting tools:

(1)Figure Palette -- Specify and arrange subplots, access workspace variables for plotting or editing, and add annotations.

(2)Plot Browser -- Select objects in the graphics hierarchy, control visibility, and add data to axes.

(3)Property Editor -- Change key properties of the selected object. Click Inspector for access to all object properties.

The following picture shows a figure with the plotting tools enabled.

4.Plotting Tools and MATLAB Commands

You can enable the plotting tools on any graph, even if you created it using MATLAB commands. For example, suppose you create the following graph.

t = 0:pi/20:2*pi;
y = exp(sin(t));
plotyy(t,y,t,y,'plot','stem')
xlabel('X Axis')
ylabel('Plot Y Axis')
title('Two Y Axes')

This graph contains two y-axes, one for each plot type (lineseries and stem graphs). The plotting tools make it easy to select any of the objects that the graph contains and set their properties.

For example, adding a label for the y-axis that corresponds to the stem plot is easily accomplished by selecting that axes in the Plot Browser and setting the YLabel property in the Property Editor.

四、Arranging Graphs Within a Figure

You can place a number of axes within a figure by selecting the layout you want from the Figure Palette. For example, the following picture shows how to specify four 2-D axes in the figure.

 

Select the axes you want to target for plotting. You can also use the subplot command to create multiple axes.

五、Selecting Plot Types

You can use the Plot Catalog to select from a variety of techniques for plotting data. To access the Plot Catalog,

1.Select the variables you want to plot in the Figure Palette.

2.Right-click to display the context menu.

3.Select More Plots to display the catalog.

MATLAB displays the Plot Catalog with the selected variables ready to plot, once you select a plot type.

 

原创粉丝点击