Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider the following:

SetOptions[Histogram, BarOrigin -> Left, 
  Frame -> {{True, None}, {True, None}}, FrameTicks -> Automatic];

data1 = {Table[1, {i, 5}], Table[5, {i, 50}], Table[3, {i, 25}], 
   Table[4, {i, 20}]};
data2 = {Table[1, {i, 3}], Table[5, {i, 20}], Table[3, {i, 25}]};
data3 = {Table[1, {i, 3}], Table[5, {i, 20}], Table[4, {i, 15}]};

histo1 = Histogram[data1]
histo2a = Show[Histogram[data1, ChartElements -> None],Histogram[data2]]
histo3a = Show[Histogram[data1, ChartElements -> None],Histogram[data3]]

histo2b = Show[Histogram[data1], Histogram[data2, ChartStyle -> Red]]    
histo3b = Show[Histogram[data1], Histogram[data3, ChartStyle -> Red]]

I would like to use the same frame/coordinate system for histo2a and histo3a as in histo1. histo3b shows how it should be (only without the grey part) and histo2a how it should not be. histo2bin addition shows the disadvantage of the Show[]-approach (one bar exceeds the frame).

Due to the latter, I was trying to extract the FrameTicks-values from histo1 and to use them for Histogram[data2] and Histogram[data3] but neitherOptions[histo1,FrameTicks],AbsoluteOptions[histo1,FrameTicks]norHistogramList[data1]` return help.

Now I would like to use exactly the same frame ticks, which were calculated based on data1 for histo2.

Neither Options[histo1,FrameTicks], AbsoluteOptions[histo1,FrameTicks] or HistogramList[data1] help. Has anyone an idea?

share|improve this question
    
So Histogram[data2,{HistogramList[data1][[1]]}] does not do what you want ? –  b.gatessucks Mar 24 '12 at 12:31
    
Do you want also the same bins used? –  belisarius Mar 24 '12 at 14:23
    
possible duplicate of Retrieving PlotRange form BarChart –  rm -rf Mar 24 '12 at 15:33
    
No, please see below. –  John Mar 25 '12 at 11:48

1 Answer 1

Perhaps:

SetOptions[Histogram, BarOrigin -> Left, 
  Frame -> {{True, None}, {True, None}}, FrameTicks -> Automatic];

data1 = Table[BesselJ[1, x], {x, 0, 500}];
data2 = Table[BesselJ[1, x], {x, 0, 100}];
GraphicsGrid[{{
   histo1 = Histogram[data1],
   histo2 = Histogram[data2],
   Show[
    Histogram[data2, ChartElements -> None], 
    Histogram[data1, {HistogramList[data2][[1]]}]]}}]

enter image description here

Edit

use just

Show[Histogram[data2, ChartElements -> None], Histogram[data1]]

if you don't want to reuse the same bins:

enter image description here

share|improve this answer
    
This is almost, what I was looking for, but please take a look at my edit. –  John Mar 25 '12 at 15:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.