Suppose that I make a plot of $x^2$ vs. $x$:

myPlot = Plot[x^2, {x, -1, 1}, Frame -> True]


If I click on the plot, I see the orange handles with which I can resize the plot:


Now, suppose that I want to actually crop the plot -- I would like to effectively shrink the orange box so that some of the plot is actually cropped. (Why in the world would I want to do this? It's a long story...)

I have found, from answers to a question that I previously asked, that this is possible using ImagePad with negative arguments. For example, suppose that I want to crop 40 pixels off the right side of the plot. I can do the following:

ImagePad[myPlot, {{0, -45}, {0, 0}}]


It looks good so far. However, when I resize the resulting cropped plot by dragging the orange handles, it looks like the image has been rasterized:


But, in contrast, I need the image to remain a vector image (non-rasterized) after cropping. Is that possible? I am running both version 8 and 9.

  • $\begingroup$ Just using PlotRange is no option? Like: Plot[x^2, {x, -1, 1}, Frame -> True, PlotRange -> {{-1, 0.5}, Automatic}] $\endgroup$ Commented Mar 8, 2014 at 16:50
  • $\begingroup$ Or after the fact: Show[plot, PlotRange -> ...] $\endgroup$
    – Szabolcs
    Commented Mar 8, 2014 at 16:50
  • $\begingroup$ @PinguinDirk Unfortunately, no, just PlotRange is not an option for me. I need to be able to crop the entire image -- including white space, frames, frame ticks, and frame labels. $\endgroup$
    – Andrew
    Commented Mar 8, 2014 at 16:54
  • $\begingroup$ @Andrew I'm not sure I understand. Why can't you just not use frames and labels then? Show[... Frame -> False] $\endgroup$
    – Szabolcs
    Commented Mar 8, 2014 at 16:58
  • 2
    $\begingroup$ @Andrew LevelScheme doesn't use Mathematica's special built-in frame. It draws its own frame, so setting PlotRange on the output should in fact crop the frame as well. $\endgroup$
    – Szabolcs
    Commented Mar 8, 2014 at 17:06

2 Answers 2


You can use Inset (this is what the interactive editor does basically).

Example: The variable crop consists of image scaled coordinates in the order

{{xmin, xmax}, {ymin, ymax}}

In this example, the value ymax is greater than one, which extends the image beyond the boundary of the original plot.

myPlot = Plot[x^2, {x, -1, 1}, Frame -> True];
croppedPlot =
 With[{iSize = 350. {1, 1/GoldenRatio},
       crop = {{0.1, 0.8}, {0.2, 1.2}}}, 
    Inset[Show[myPlot, ImageSize -> iSize], {0., 0.}, ImageScaled[{0., 0.}]],
    PlotRange -> crop iSize, ImageSize -> crop iSize]
Framed[croppedPlot, FrameMargins -> 0, FrameStyle -> Red]

Mathematica graphics


I just realized from this Wolfram page that one can crop the "orange box" by Ctrl+dragging one of the orange handles.

myPlot = Plot[x^2, {x, -1, 1}, Frame -> True]


and obtain


This seems to work pretty well for the question that I asked. A programmatic method would be better, but this use of the front end is OK.

  • $\begingroup$ (+1)Very Nice Solution. :) $\endgroup$ Commented May 20, 2017 at 21:41
  • $\begingroup$ How can I export the cropped picture? $\endgroup$ Commented May 20, 2017 at 21:43

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