Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that one can retrieve PlotRange of a plot by using


but that won't work on Histogram. Here an example:


data = {-1.2056, -1.46192, -1.30053, -2.52879, -0.99636, -1.73904, -1.164,
-1.83398,-0.97505, -0.503256, -0.63802, -0.785963, -0.711821, -0.820439, -1.8699,
-3.9659, -1.4456, -1.67021, -1.42009, -2.5644, -1.45002, -1.27806, -1.66529,
-1.67073, -3.31102, -3.38638};
Histogram[%, PlotRange -> Automatic];
AbsoluteOptions[%, PlotRange]

When running the code I get the following message.

PlotRange::prng: Value of option PlotRange -> {{All,All},{-4.,0.}} is not All,
Full, Automatic, a positive machine number, or an appropriate list of range
specifications. >>

As I understood the documentation, PlotRange need to be of a certain format (e.g. two numbers) and {{All,All},{-4.,0.}} apparently does not fit to that format, for which reason Mathematica won't give me back the PlotRange of my histogram.

Does anybody know how I can get the PlotRange of a Histogram anyway? By the way: In the first place, it will only make sense to get hold of the second value of PlotRange (in my example: {-4.,0.}) since one can calculate the first one for instance through {0,Length[data]}.

Many thanks!


share|improve this question

migrated from Jul 26 '12 at 19:41

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted
data = {-1.2056, -1.46192, -1.30053, -2.52879, -0.99636, -1.73904, \
-1.164, -1.83398, -0.97505, -0.503256, -0.63802, -0.785963, \
-0.711821, -0.820439, -1.8699, -3.9659, -1.4456, -1.67021, -1.42009, \
-2.5644, -1.45002, -1.27806, -1.66529, -1.67073, -3.31102, -3.38638};
hist = Histogram[data, PlotRange -> Automatic]
First[PlotRange /. Options[hist, PlotRange]]
share|improve this answer
Works perfect. Thank you Rolf! One more issue appeared after setting the plot range as I wanted it to be. For the second histogram Mathematica draws at the level of the minimum value a line which I cannot get rid of (e.g. by GridLines->None). Do you have any suggestions on that issue? Code: HistogramFirst=Histogram[data, PlotRange -> Automatic] HistogramSecond=Histogram[data, PlotRange -> {-8, 0}] – John Feb 10 '12 at 14:47
I do not see such a line. Which Mathematica version and which operating system are you using? – Rolf Mertig Feb 10 '12 at 23:22

You can also extract the PlotRange from the second Part of hist:

PlotRange /. hist[[2]] // First
(* {-4.`, 0.`} *)

Note: hist[[2]] contains the options

(* {AspectRatio->1/GoldenRatio, Axes->{True,True}, AxesLabel->{None,None}, 
   AxesOrigin->{-4.,0}, FrameTicks->{{Automatic, Automatic},{Automatic, Automatic}}, 
   GridLines->{None,None}, PlotRange->{{-4.,0.},{All,All}},
       {Scaled[0.02],Scaled[0.1]}},Ticks->{Automatic,Automatic}} *)
share|improve this answer

Your Answer


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.