How to exclude bins from a bi-variate histogram
7 views (last 30 days)
Show older comments
Hi, I have been some of the bins from the a bi-variate histogram of the following density plot/histogram. I don't want to have my histogram horizontally between x>=-0.002 & x<0.002 and vertically between y>=-0.002 & y<0.002.
I have tried the following code
xL = xpos>=-0.002 & xpos<0.002; % xpos is the position in x-axis
x = xpos(~xL,:);
yL = ypos>=-0.002 & xpos<0.002; % ypos is the position in y-axis
y = ypos(~yL,:);
h = histogram2(x,y,[100,100],'DisplayStyle','tile','ShowEmptyBins','on');
But it is giving error as my length of x and y are different. I will appreciate if anyone let me know how to make my histogram2 plot excluding those region. Thanks in advance.
0 Comments
Answers (2)
Steven Lord
on 3 Aug 2018
Don't eliminate data points from your xpos and ypos arrays. Instead, specify XBinLimits and YBinLimits when you call histogram2.
Image Analyst
on 3 Aug 2018
You say you have an image of "bins from the a bi-variate histogram of the following density plot/histogram." So the data in the image already represents counts (a histogram). Why why then are you calling histogram2()? Why are you calling histogram on a histogram? And what is xpos and ypos exactly? Is that like what you'd get from meshgrid, basically a 2-D array of the x and y coordinates? If so, then what variable is displayed in the image?
Do you just want to crop the displayed/existing histogram to be a smaller image (smaller range)?
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!