matlab绘制散点密度,MATLAB实例:散点密度图

MATLAB实例:散点密度图

MATLAB绘制用颜色表示数据密度的散点图

1. demo.m

% 用颜色表示数据密度的散点图

data_load=dlmread('E:\scanplot\gauss.txt');

X=data_load(:,1:2);

scatplot(X(:,1),X(:,2),'circles', sqrt((range(X(:, 1))/30)^2 + (range(X(:,2))/30)^2), 100, 5, 1, 8);

% colormap jet

print(gcf,'-dpng','散点密度图.png');

2. scatplot.m

function out = scatplot(x,y,method,radius,N,n,po,ms)

% Scatter plot with color indicating data density

% https://www.mathworks.com/matlabcentral/fileexchange/8577-scatplot

% USAGE:

% out = scatplot(x,y,method,radius,N,n,po,ms)

% out = scatplot(x,y,dd)

%

% DESCRIPTION:

% Draws a scatter plot with a colorscale

% representing the data density computed

% using three methods

%

% INPUT VARIABLES:

% x,y - are the data points

% method - is the method used to calculate data densities:

% 'circles' - uses circles with a determined area

% centered at each data point

% 'squares' - uses squares with a determined area

% centered at each data point

% 'voronoi' - uses voronoi cells to determin data densities

% default method is 'voronoi'

% radius - is the radius used for the circles or squares

% used to calculate the data densities if

% (Note: only used in methods 'circles' and 'squares'

% default radius is sqrt((range(x)/30)^2 + (range(y)/30)^2)

% N - is the size of the square mesh (N x N) used to

% filter and calculate contours

% default is 100

% n - is the number of coeficients used in the 2-D

% running mean filter

% default is 5

% (Note: if n is length(2), n(2) is tjhe number of

% of times the filter is applied)

% po - plot options:

% 0 - No plot

% 1 - plots only colored data points (filtered)

% 2 - plots colored data points and contours (filtered)

% 3 - plots only colored data points (unfiltered)

% 4 - plots colored data points and contours (unfiltered)

% default is 1

% ms - uses this

你可能感兴趣的:(matlab绘制散点密度)