No BSD License  

Highlights from
scatplot

4.0

4.0 | 6 ratings Rate this file 34 Downloads (last 30 days) File Size: 6.34 KB File ID: #8577
image thumbnail

scatplot

by alex sanchez

 

27 Sep 2005 (Updated 05 Dec 2005)

Scatter plot with color indicating data density.

| Watch this File

File Information
Description

% Scatter plot with color indicating data density
%
% 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 marker size for filled circles
% default is 4
%
% OUTPUT VARIABLE:
% out - structure array that contains the following fields:
% dd - unfiltered data densities at (x,y)
% ddf - filtered data densities at (x,y)
% radius - area used in 'circles' and 'squares'
% methods to calculate densities
% xi - x coordenates for zi matrix
% yi - y coordenates for zi matrix
% zi - unfiltered data densities at (xi,yi)
% zif - filtered data densities at (xi,yi)
% [c,h] = contour matrix C as described in
% CONTOURC and a handle H to a contourgroup object
% hs = scatter points handles

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
18 Nov 2005 m2 howard

nice, simple, and effective!

03 Dec 2005 Birajashis Pattnaik

Ya simple but impressive,Good

03 May 2006 J C

Nice work. thank you !

18 Apr 2007 John D'Errico

A very nice utility for visualizing scattered data in 2-d. Excellent help, an H1 line, defaults for the variables, internal comments, etc.

A flaw is there is no error checking done on the parameters for viability. For example, the method argument is described as taking on one of 'circles', 'squares', or 'voronoi'. However, the code checks only the first two characters, both of which must be correct. This feature is undocumented. Note that strcmpi or strmatch are easy to use tools that will check for any shortened versions of the options. You can even ignore capitalization.

Similarly, there is no error checking on the po (plot options) argument. If you pass in a 5, you get an arbitrary result.

I would have liked to give this a 5 rating, and will happily raise my rating.

02 Jun 2007 New Sung

It's what I am just looking for. Very nice! Thank you.

28 Jan 2008 Garret Duffy

Excellent and useful plotting utility. Specification of command-line parameters is tricky however. Perhaps a runtime feedback of what input parameters were specified would be useful.

15 Feb 2011 Hongxiao Jin

%this works fine for simple show
function hh=scatterC(varargin,n,method)
if nargin<2
    n = 100; %bins
    method='p'%pcolor
end
if nargin<3
    method='p'
end

[N C]=hist3(varargin,[n,n]);
N(find(N==0))=NaN;
[X Y]=meshgrid(C{1},C{2});
switch method
    case 'p'
        pcolor(X,Y,N);shading flat;
    case 'c' %contourf
        contourf(X,Y,N,'EdgeColor','None');
end

Please login to add a comment or rating.
Updates
05 Dec 2005

more efficient and cleaner

Tag Activity for this File
Tag Applied By Date/Time
graphics import alex sanchez 22 Oct 2008 08:00:56
graphics export alex sanchez 22 Oct 2008 08:00:56
scatter plot alex sanchez 22 Oct 2008 08:00:56
color alex sanchez 22 Oct 2008 08:00:56
export alex sanchez 22 Oct 2008 08:00:56
graphics alex sanchez 22 Oct 2008 08:00:56
import alex sanchez 22 Oct 2008 08:00:56
data density alex sanchez 22 Oct 2008 08:00:56
scatter plot Mark 20 Jan 2011 12:02:13

Contact us at files@mathworks.com