Histc bars show outside of axes (if xlim is narrower)
Ältere Kommentare anzeigen
Hi everyone!
I've been coding a GUI which reads an image ("imshow") and makes an histogram ("histc" kind) in a certain axes. The problem I'm having is that if I define the "xlim" narrower than the edges of the "histc", the bars which edges are out of the limits still show up (out of the axes).
http://postimg.org/image/r3mtanscr/ (printscreen)
The curious thing is that I've tried putting a simple "figure" command prior to the "bar" plot and as it shows on a different window (due to the "figure") the problem I talked about doesn't occur...
http://postimg.org/image/ol149z6mj/ (printscreen)
One other thing... does anyone know how to do a plotyy with a plot and a histc bar in one line? I only know how to do it with a normal bar plot and then replace it with an histc bar plot (with plotty(...,@bar,@plot)).
the coding related to the histogram:
handles.edges=handles.min_ratio:(handles.max_x-handles.min_x)/9:... handles.max_x; %this vector goes from 1 to 10
data=handles.image(:); %turning the image matrix into an array
% creating the histogram values (relative counts, from 0 to 1) handles.histog=histc(data,handles.edges)/sum(hist(data,handles.edges));
axes(handles.histogram) % selects the axes cla(handles.histogram) % cleans the axes
hb=bar(handles.edges,handles.histog,'histc'); % bar plot
set(hb,'FaceColor','g') % green bars xlim([6 10]) % x values limits for the bar plot
Thank you in advance!
Antworten (0)
Kategorien
Mehr zu Axis Labels finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!