matlab scatter plot using colorbar for 2 vectors -
i have 2 columns of data. x = model values of nox concentrations , y = observations of nox concentrations. now, want scatter plot x, y (markers varying colors) colourbar show me counts (i.e. number of data points in range). x , y daily data year, i.e. 365 rows.
if understand correctly, real problem creating color information, is, creating bivariate histogram. luckily, matlab has function, hist3, in statistics & machine learning toolbox. syntax is
[n,c] = hist3(x,nbins) where x m-by-2 matrix containing data, , nbins 1-by-2 vector containing number of bins in each dimension. return value n matrix of size nbins(1)-by-nbins(2), , contains histogram data. c 1-by-2 cell array, containing bin centers in both dimensions.
% generate sample data x = randn(10000, 1); y = x + rand(10000, 1); % generate histogram [n,c] = hist3([x,y], [100,100]); % plot imagesc(c{1},c{2},n); set(gca,'ydir','normal'); colormap(flipud(pink)); colorbar; result:


Comments
Post a Comment