Hi.
I have created a barchart on a figure and wanting to change the number of bins by adding a popupmenu to the figure. I assign the callback to this a function called setBins.
% Create pop-up menu on figure
popup = uicontrol('Style', 'popup',... 'String', {'5','10','20','50','100','200','500','1000','2000'},... 'Position', [10 0 80 30],... 'Callback', @setBins); function setBins(source,event) fig = gcf; ax = fig.CurrentAxes; cla(ax) val = source.Value indx = source.String nbins=(indx(val,1)) nbins=str2double(nbins) data=getappdata(0,'data'); %Data has already been saved using setappdata
[counts,xb]=hist(data(:,3),nbins); %IMHIST ONLY HANDLES 8 & 16 BIT IMAGES, NOT 12BIT
bar(log10(xb),counts,'b','EdgeColor','b'); %Replot with user defined number of bins
grid on; hold on xlim([min(log10(xb)) max(log10(xb))]) xlabel('log(Intensity)') ylabel('Frequency') set(gca,'fontsize',8) hold off
My question is, this works fine with one plot on the figure. If however, this figure has two subplots and this is subplot(1,2,1), how would I get the above code just to apply to this subplot?
Thanks Jason
Best Answer