From: Michael Coughlin on 29 Jun 2010 09:48 Hi, I have two data sets, of two different lengths (which makes this difficult), which I would like to make a histogram of (using the same bin size and min max). When I go to make a histogram of both of these, I have tried using a hold command: hold on hist(z2,bins) i = findobj(gca,'Type','patch'); set(i,'FaceColor','b','EdgeColor','w') hold off While this results in the correct histogram, this object command grabs both histograms and turns them blue, while I would like them two different colors. Can someone help me? Thank you, Michael
From: Ashish Uthama on 29 Jun 2010 10:10 Set the facecolor after you plot the first to red. The next one should come up as blue, the default. (Also, In case you try doing this after call to both HIST instances, I imagine the order of the elements in 'i' would correspond to the order in which HIST was called).
From: Michael Coughlin on 17 Jul 2010 09:04 Hi, So this worked very well for linear scale, but turning this into log scale seems a little more tricky. I have looked at the mathworks page for log scale histograms, but doing this with more than one color seems tricky. http://www.mathworks.com/support/solutions/en/data/1-2ZUTKK/?solution=1-2ZUTKK Does anyone have ideas for making a log histogram with two different colors? I attach my current code below (which does not work, and is based on the one color histogram from the page above). Michael plotnum =1; bins=5:0.5:35; x1=load('20100620_yes.txt'); x2=load('20100621_yes.txt'); x3=load('20100622_yes.txt'); y1=load('20100620_no.txt'); y2=load('20100621_no.txt'); y3=load('20100622_no.txt'); z1=[x1(:,2);x2(:,2);x3(:,2)]; z2=[y1(:,2);y2(:,2);y3(:,2)]; set(0,'defaultaxesfontsize',20); %daily spectral-variation plots remove_zero_z1=find(z1==0); z1(remove_zero_z1)=.1; remove_zero_z2=find(z2==0); z2(remove_zero_z2)=.1; figure(plotnum) set(gcf, 'PaperSize',[10 8]) set(gcf, 'PaperPosition', [0 0 10 8]) clf hist(z1,bins); ph = get(gca,'children'); vn = get(ph,'Vertices'); set(ph,'Vertices',vn); h = findobj(gca,'Type','patch'); set(h,'FaceColor','r','LineStyle','--') xlabel('Max Radon Power') ylabel('Counts') plot_title='Histogram Comparing Airplane Events vs. Non-Airplane Events'; title(plot_title) hold on hist(z2,bins); %ph = get(gca,'children'); %vn = get(ph,'Vertices'); %set(ph,'Vertices',vn); hold off hold on plot(16,0:0.1:5,'k-.','LineWidth',3) hold off xlim([5 35]); set(gca,'YScale','log'); saveas(gcf,'airplane_hist.jpeg'); %close(plotnum); plotnum = plotnum+1; "Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.ve2ezjena5ziv5(a)uthamaa.dhcp.mathworks.com>... > > Set the facecolor after you plot the first to red. The next one should > come up as blue, the default. > (Also, In case you try doing this after call to both HIST instances, I > imagine the order of the elements in 'i' would correspond to the order in > which HIST was called).
From: us on 17 Jul 2010 10:31 "Michael Coughlin" <coughlim(a)carleton.edu> wrote in message <i1s9o4$8od$1(a)fred.mathworks.com>... > Hi, > > So this worked very well for linear scale, but turning this into log scale seems a little more tricky. > > I have looked at the mathworks page for log scale histograms, but doing this with more than one color seems tricky. > > http://www.mathworks.com/support/solutions/en/data/1-2ZUTKK/?solution=1-2ZUTKK > > Does anyone have ideas for making a log histogram with two different colors? I attach my current code below (which does not work, and is based on the one color histogram from the page above). > > Michael > x1=load('20100620_yes.txt'); > x2=load('20100621_yes.txt'); > x3=load('20100622_yes.txt'); > y1=load('20100620_no.txt'); > y2=load('20100621_no.txt'); > y3=load('20100622_no.txt'); well... how do you think CSSMers can be of any help given this input, which is not available to anyone but you... THINK - then POST... us
From: Michael Coughlin on 17 Jul 2010 10:53
Hi, Absolutely, but I am looking for a method/idea for how to do it, not an exact code. You can easily replace both of the hist command with: hist(randn(100,1)); If you actually want to code it, but I don't think you do. I was just presenting how I was attacking the problem, and all I was requesting was an idea of how they would attack the problem (more generally). Thank you, Michael "us " <us(a)neurol.unizh.ch> wrote in message <i1ser8$ko0$1(a)fred.mathworks.com>... > "Michael Coughlin" <coughlim(a)carleton.edu> wrote in message <i1s9o4$8od$1(a)fred.mathworks.com>... > > Hi, > > > > So this worked very well for linear scale, but turning this into log scale seems a little more tricky. > > > > I have looked at the mathworks page for log scale histograms, but doing this with more than one color seems tricky. > > > > http://www.mathworks.com/support/solutions/en/data/1-2ZUTKK/?solution=1-2ZUTKK > > > > Does anyone have ideas for making a log histogram with two different colors? I attach my current code below (which does not work, and is based on the one color histogram from the page above). > > > > Michael > > > x1=load('20100620_yes.txt'); > > x2=load('20100621_yes.txt'); > > x3=load('20100622_yes.txt'); > > y1=load('20100620_no.txt'); > > y2=load('20100621_no.txt'); > > y3=load('20100622_no.txt'); > > well... how do you think CSSMers can be of any help given this input, which is not available to anyone but you... > THINK - then POST... > > us |