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.

I recently ran a rather time intensive calculation and plotted the results in a histogram by simply called Histogram[data]. However, because of a rather serious error on my part, I recently lost my original data and all I have is the histogram plot.

I need to change the vertical cut-off on the histogram (it will cut off any bars with an event count >= N). I can hover over the bars and read the values, so I know the information is there, but how can I change the value of N for the vertical cutoff?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted
 data = RandomVariate[NormalDistribution[0, 1], 200];
 hh = Histogram[data]

enter image description here

Copy the graphic you have (Ctrl+C) and in a new cell type gr= and paste your graphic (Ctrl+V):

enter image description here

 gr /. RectangleBox[x : {_, _}, y : {y1_, y2_}, z__] :> 
       RectangleBox[x, {y1, Min[y2, 30]}, z]

gives

enter image description here

Update: An alternative approach is to replace the PlotRange and PlotRangePadding options of gr:

 gr /. {HoldPattern[PlotRange -> _] :> PlotRange -> {0, 30},
     HoldPattern[PlotRangePadding -> _] :> PlotRangePadding -> 0}

enter image description here

You can also use Show with PlotRange and PlotRangePadding options:

 Show[gr, PlotRange -> {0, 30}, PlotRangePadding -> 0]

which gives an output identical to the last one.

share|improve this answer
    
I recieve an error saying the FrontEnd 'If is not a graphics primitive or directive. –  Nikki Dec 24 '12 at 13:14
    
I cannot regenerate the histogram, I only have the graphic. –  Nikki Dec 24 '12 at 13:15
    
@Nikki, I updated with the answer showing how to use the graphic you have. Regarding the error message in your first comment, I am not getting any error messages (using Windows Vista 64bit, Mathematica Version 9). –  kguler Dec 24 '12 at 13:33
    
That's effectively what I tried earlier... hmm... does it still work for you if you quit the kernel and then try it? –  Nikki Dec 24 '12 at 13:49
    
Yes, it does work with a fresh kernel. Just checked that it also works in Version 8.0.4.0. Do you get the same error message when you use the methods on a new histogram? If not, perhaps you can post the FullForm of your graphic to see if there is anything specific that is causing the issue. (To get the FullForm of your graphic, just copy-paste it inside the brackets in FullForm[] in a new cell.) –  kguler Dec 24 '12 at 14:09
show 1 more comment

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.