Say I have some plot

plot = Plot[Sin[x], {x,0,10}] (*as an example*)

Is there a way I can get the x and y axes min/max values from the "plot" variable?

If I wanted the image sizes I could do


I'm looking for something like this but for the axes (either total length or min/max values). I want to draw some additional graphics on the plot but it needs to be appropriately scaled.


  • $\begingroup$ I can't give a complete answer from mobile, but you will want to check out the Scaled function, plus my GetGeometry function in my recent question "Context dependent functions" $\endgroup$
    – LLlAMnYP
    Mar 26 '15 at 18:52
  • $\begingroup$ are you actually looking for the coordinate range on the plot or are you thinking in terms of the image? The plots Plot[10^6 Sin[x],{x,0,10}] and Plot[Sin[x],{x,0,10}] look very similar, you could place them on top of each other, however the y-range of one is +-10^6, while the other is +-1. Both plots would be 600 points wide and 600/GoldenRatio high. Axes dimensions in printer points would be similar. $\endgroup$
    – LLlAMnYP
    Mar 26 '15 at 19:01
  • $\begingroup$ Strongly related: "How to get the real PlotRange?" $\endgroup$ Mar 26 '15 at 23:25


PlotRange /. AbsoluteOptions[plot]
Last @@ AbsoluteOptions[plot, PlotRange]
PlotRange /. plot[[2]]

all give

(* {{0.,10.},{-0.999999,1.}} *)

Note: Regarding usage of PlotRange as a function, it is undocumented, and the earliest reference I could find on this site is this answer dated Oct 11, 2012:

Since then, also used in

  • 1
    $\begingroup$ +1 PlotRange[plot] is a very interesting answer - an option rule that can behave as a function. I didn't see anything in the documentation that PlotRange (or other options, for that matter) could behave in this fashion. $\endgroup$ Mar 26 '15 at 21:16
  • $\begingroup$ @bob, thank you for the vote. It is not documented afaik. My initial discovery was pure accident. I used it in several answers on this site but i cannot find any of them when i search now. $\endgroup$
    – kglr
    Mar 26 '15 at 21:24
  • $\begingroup$ Mr.Wizard could not recall recently where he learnt that PlotRange trick. Now I know it was probably from you and that it is indeed not documented ... interesting ;) $\endgroup$
    – SquareOne
    Mar 26 '15 at 21:43
  • $\begingroup$ @SquareOne, still searching earlier posts - no success so far. $\endgroup$
    – kglr
    Mar 26 '15 at 21:48
  • $\begingroup$ This is how to you can make the additional functionality of the Options visible: ClearAttributes[Evaluate[Options[Graphics]〚All, ,1〛], ReadProtected] Information /@ Options[Graphics]〚All, 1〛 unfortunately the result is that PlotRange is the only option of Graphics that is also a Function. Its Definition is: PlotRange[- GraphicsArray-]:=With[{SystemDumpres=Graphics[-GraphicsArray-]},PlotRange[SystemDumpres]/;SystemDumpGRTest[SystemDumpres]] and something similar with -RasterGraphics-. Really interesting, maybe there are more options like this to find! $\endgroup$
    – sacratus
    Mar 27 '15 at 20:24

FilterRules[AbsoluteOptions[plot], PlotRange] does the trick

(*{PlotRange -> {{0., 10.}, {-0.999999, 1.}}} *)

Not sure if this is an exhaustive answer.

  • $\begingroup$ Uh... yeah, obvious solution is obvious. My thinking gets boxy after 7 hours at Schiphol. The harder part is getting the absolute (or printer, or whatever you wish to call them) coordinates, at which I hinted in my comment. $\endgroup$
    – LLlAMnYP
    Mar 26 '15 at 18:57

Anyway, while I wait for my flight, here's some code that'll give you everything there is to know about a plot.

GetGeometry[g_Graphics] :=





The code above had some excessive definitions which I removed (the full version of my function calculates the amount of padding necessary for the ticks and frame labels).

Most of the output of the function is self-explanatory, but "PlotRangeSize" gives the size of the PlotRange in printer points and "ImageScaledToScaled" gives the coordinates of Scaled[{0,0}] and Scaled[{1,1}] in terms of ImageScaled.

Cases[Plot[Sin[x], {x, 0, 10}], _[PlotRange, x_] :> x, -1][[1]]
(*{{0, 10}, {-0.999999, 1.}})*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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