matlab - Is it possible to make hist3 plots smoother? -
i use hist3() function plot density of points. creates grid , finds number of points in each grid, creates plot. colors on plot discrete. there option make distribution smooth, i.e. make transition 1 color smoother. cells of grid have different colors, grin yellow , distribution not apparent.
i use following code.
axis equal; colormap(jet); n = hist3(final',[40,40]); n1 = n'; n1( size(n,1) + 1 ,size(n,2) + 1 ) = 0; xb = linspace(min(final(:,1)),max(final(:,1)),size(n,1)+1); yb = linspace(min(final(:,2)),max(final(:,2)),size(n,1)+1); pcolor(xb,yb,n1);
thanks in advance.
you may want use gridfit
function matlab file exchange. smooth effect comes both interpolation (more points plot) , full use of available color (colormap jet
here). note edgecolor
set none
so black lines removed.
as used here, takes output of hist3 (20x20 matrix) , interpolate (100x100). plot surface using surf
. in addition, can uncomment camlight
option.
final = randn(1000,2)'; n = hist3(final',[20,20]); %binning figure('color','w'); %your code pcolor subplot(1,2,1); axis equal; colormap(jet); n1 = n'; n1( size(n,1) + 1 ,size(n,2) + 1 ) = 0; xb = linspace(min(final(:,1)),max(final(:,1)),size(n,1)+1); yb = linspace(min(final(:,2)),max(final(:,2)),size(n,1)+1); pcolor(xb,yb,n1) %density gridfit function subplot(1,2,2); nb_interp_point = 100; [x,y] = meshgrid(1:size(n,1),1:size(n,2)); zgrid = gridfit(x(:), y(:), n, nb_interp_point, nb_interp_point); surf(zgrid,'edgecolor','none') set(gca,'ydir','reverse'); view(-90,90); % camlight right % lighting phong
here result
Comments
Post a Comment