Example -- Plotting the Mean of a Data Set
To add a plot of the mean of a data set to a graph,
Using a Legend with Data Statistics
When you activate the Data Statistics tool, it calculates statistics for the plotted data and automatically adds a legend to the graph, if the graph doesn't already have one.
When you add a plot of one or more statistics to the graph, the Data Statistics tool adds an entry in the legend for the new plot. The Data Statistics tool assigns the plotted statistic a descriptive name that identifies it in the legend. In the example, the plotted statistic has the name
y mean in the legend.
Formatting Plots of Data Statistics
The Data Statistics tool uses color and line style to distinguish the plots of statistics from the other plots in a graph. However, as with any other plot in a graph, you can change these characteristics.
|Note Do not edit the format of the plots of data statistics until you are finished adding them to a graph. If you edit a plot of data statistics, delete the plot, and then add it back, any formatting you did to the plotted statistics will be lost.|
To modify the properties of a plotted statistic,
Statistics Plotted by the Data Statistics Tool
|Note You can only use the Data Statistics tool to generate statistics for two-dimensional data (vectors and matrices).|
The following table lists the statistics calculated by the Data Statistics tool. The table includes the name of the MATLAB function used to calculate the statistic. For more information about these statistical functions, see Basic Data Analysis Functions in the MATLAB Math documentation.
||Largest value in the data set
||Smallest value in the data set
||Average of all the values in the data set
||Middle value in the data set
||Interval between the lowest value and the highest value in the data set. The Data Statistic tool does not plot the range statistic.
||A measure characterizing the amount of variation among the values in the data set
Note: The Data Statistics tool uses two lines to plot the standard deviation in a graph. The lines represent the boundaries of one standard deviation on either side of the mean of the data set.
Automatic Updating of Statistics
If you have the Data Statistics tool displayed and you change the x-data or y-data of a plot, the Data Statistics tool automatically regenerates the statistics for that plot.
Viewing Statistics for Multiple Plots
The Data Statistics tool calculates basic statistics for every 2-D plot in a graph, but displays the statistics for only one plot at time.
To view the statistics for a particular plot in a graph,
data1to identify the first plot,
data2to identify the second plot, and so on.
Saving Statistics to the MATLAB Workspace
To save the statistics generated by the Data Statistics tool to the MATLAB workspace, follow this procedure:
The Data Statistics tool saves each set of statistics in a structure. For example, if you save the set of statistics on the x-data in the census in the variable
census_dates, the contents of the structure looks like this.
|Adding Plots of Basic Statistics to Graphs||Annotating Graphs|
© 1994-2005 The MathWorks, Inc.