From: Steven_Lord on 19 Jul 2010 12:55 "Michael Coughlin" <coughlim(a)carleton.edu> wrote in message news:i1sg4f$9bs$1(a)fred.mathworks.com... > 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). Us was pointing out that without knowing what the data looked like (in particular, what data type and what size the variables were) it's hard to know what specific problem you're trying to solve. All too often in this newsgroup, people post questions that aren't well-posed and responding with "Well, what I posted was just a sample, I'm really interested in doing this other thing" when someone responds with a suggestion for how to solve the posted problem. So, can you please post a small section of code that anyone with a sufficiently-recent version of MATLAB can copy into their MATLAB session to run (without any references to data files to which users may/do not have access) and explain SPECIFICALLY how that code's behavior differs from what you want that code to do? Thanks. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Kelly Kearney on 19 Jul 2010 14:34
"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). Just collect the output of the histogram command, then plot using a bar plot. Rather than using a log scale axis, take the log of your data and then plot on a linear scale. If you really want the log-plot appearance, you can play around with the tick locations and tick labels. % Create some data y{1} = randn(1000,1); y{2} = randn(2000,1); y{3} = randn(3000,1); % Create histograms x = -3:.2:3; n = zeros(length(x), length(y)); for iy = 1:length(y) n(:,iy) = hist(y{iy},x); end hb = bar(x,log10(n)); |