Why does my histogram go out of its frame?
10 views (last 30 days)
Show older comments
I draw a histogram from an image using imhist just like this:
subplot(2, 2, 3), imhist(a+50), title("Blob1 lighter hist");
and then when I plot it, the lines are getting out of the frame and I don't know why.
Please someone help me, I really don't understand what is going on with my Matlab program and I don't find anything online.
2 Comments
Cris LaPierre
on 13 May 2023
%% Blobs
figure;
a = imread("blobs1.png");
b = imread("blobs2.png");
c = imread("blobs3.png");
d = imread("blobs4.png");
subplot(2, 2, 1), imshow(a), title("Blob1");
subplot(2, 2, 2), imshow(b), title("Blob2");
subplot(2, 2, 3), imshow(c), title("Blob3");
subplot(2, 2, 4), imshow(d), title("Blob4");
figure;
subplot(2, 2, 1), imhist(a), title("Blob1");
subplot(2, 2, 2), imhist(b), title("Blob2");
subplot(2, 2, 3), imhist(c), title("Blob3");
subplot(2, 2, 4), imhist(d), title("Blob4");
disp('Blob1');
mean(a(:));
std(double(a(:)));
disp('Blob2');
mean(b(:));
std(double(b(:)));
disp('Blob3');
mean(c(:));
std(double(c(:)));
disp('Blob4');
mean(d(:));
std(double(d(:)));
Answers (3)
Cris LaPierre
on 13 May 2023
I'm able to reproduce as well. I suggest reporting this here: https://www.mathworks.com/support/contact_us.html
0 Comments
Cris LaPierre
on 16 May 2023
Edited: Cris LaPierre
on 16 May 2023
I would recommend not using imhist to create your histogram. Instead, use histogram(I) or bar(counts) to visualize.
B1 = imread('blobs1.png');
figure
histogram(B1,'BinWidth',1)
xlim([0,255])
figure
counts = imhist(B1);
bar(counts)
0 Comments
Image Analyst
on 16 May 2023
I am not able to reproduce in either R2022b or R2023a. It looks perfectly fine. I'd call tech support. Maybe try a different renderer with opengl
See Also
Categories
Find more on Subplots 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!