# Rescuing a vertically clipped histogram

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?

-

 data = RandomVariate[NormalDistribution[0, 1], 200];
hh = Histogram[data]


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

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


gives

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

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


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.

-
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