Skip to Main Content Skip to Search
Product Documentation

scatterhist - Scatter plot with marginal histograms

Syntax

scatterhist(x,y)
h = scatterhist(...)
scatterhist(...,'param1',val1,'param2',val2,...)

Description

scatterhist(x,y) creates a 2-D scatterplot of the data in the vectors x and y, and puts a univariate histogram on the horizontal and vertical axes of the plot. x and y must be the same length.

The function is useful for viewing properties of random samples produced by functions such as copularnd, mvnrnd, lhsdesign.

h = scatterhist(...) returns a vector of three axes handles for the scatterplot, the histogram along the horizontal axis, and the histogram along the vertical axis, respectively.

scatterhist(...,'param1',val1,'param2',val2,...) specifies additional parameter name/values pairs to control how the plot is made. Valid parameters are the following:

Examples

Example 1

Independent normal and lognormal random samples:

x = randn(1000,1);
y = exp(.5*randn(1000,1));
scatterhist(x,y)

Example 2

Marginal uniform samples that are not independent:

u = copularnd('Gaussian',.8,1000);
scatterhist(u(:,1),u(:,2),'Direction','out')

Example 3

Mixed discrete and continuous data:

load('carsmall');
scatterhist(Weight,Cylinders,'NBins',[10 3],'Direction','out')

See Also

hist | scatter

  


 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS