From: Farid Medleg on
looking to plot 8 vectors, 2 at a time, on 4 subplots
needed:
- how to plot the histograms with no fill so when superimposed, you can see the two graphs on each subplot
- how to ensure both histograms in the same subplot utilize the same scale on the x axis
thanks
From: Wayne King on
"Farid Medleg" <farid.medleg(a)gmail.com> wrote in message <i0lh6l$f92$1(a)fred.mathworks.com>...
> looking to plot 8 vectors, 2 at a time, on 4 subplots
> needed:
> - how to plot the histograms with no fill so when superimposed, you can see the two graphs on each subplot
> - how to ensure both histograms in the same subplot utilize the same scale on the x axis
> thanks

Hi Farid, I think there are a number of ways to do this. One way:

x = randn(100,1);
y = 3+randn(100,1);
Edges = -6:0.5:6;
N = histc(x,Edges);
N1 = histc(y,Edges);
h = bar(Edges,N,'histc'); set(h,'facecolor',[1 1 1]);
hold on;
h1 = bar(Edges,N1,'histc'); set(h1,'facecolor',[1 1 1],'EdgeColor',[0 0 1], ...
'linestyle','--');

In the above, I set the EdgeColor and linestyle properties to help delineate the two histograms. There are a number of other properties you can use to do this--perhaps another solution would be better.

If you would rather specify bin centers instead of edges, you can do that in hist(). See the documentation.

Wayne