Monday, 15 March 2010

matlab - Plot point density -



matlab - Plot point density -

i trying plot point density big set of points (see image). how it? tried using code below, got error error using griddedinterpolant grid vectors not strictly monotonic increasing (i guess because points not ordered).

%# bin centers (integers) xbins = floor(min(x)):step_for_plot:ceil(max(x)); ybins = floor(min(y)):step_for_plot:ceil(max(y)); xnumbins = numel(xbins); ynumbins = numel(ybins); %# map x/y values bin indices xi = round( interp1(xbins, 1:xnumbins, x, 'linear', 'extrap') ); yi = round( interp1(ybins, 1:ynumbins, y, 'linear', 'extrap') ); %# limit indices range [1,numbins] xi = max( min(xi,xnumbins), 1); yi = max( min(yi,ynumbins), 1); %# plot 2d histogram imagesc(xbins, ybins, data), axis on %# axis image colormap hot; colorbar hold on, plot(x, y, 'b.', 'markersize',1), hold off

i solved problem using hist3. here code used:

n = hist3(data,[100,100]); n1 = n'; n1(size(n,1) + 1, size(n,2) + 1) = 0; xb = linspace(min(data(:,1)),max(data(:,1)),size(n,1)+1); yb = linspace(min(data(:,2)),max(data(:,2)),size(n,1)+1); g = figure(); h = pcolor(xb,yb,n1);

matlab plot

No comments:

Post a Comment