You can see that there are gaps on all sides of the plot between the frame and the extent of the line that I've plotted. How do I get rid of these? I'd like the frame to cover $[0,1]\times[0,1]$ and no more.

Plot[x, {x, 0, 1}, Frame -> True]

enter image description here

  • $\begingroup$ One way is to specify PlotRange as in Plot[x, {x, 0, 1}, Frame -> True, PlotRange -> {{0, 1}, {0, 1}}]. $\endgroup$ – b.gates.you.know.what Jan 31 '13 at 12:57
  • $\begingroup$ @b.gatessucks This also works; thanks! $\endgroup$ – Will Vousden Jan 31 '13 at 13:22
  • $\begingroup$ Related: (3618), (7453), (9346) $\endgroup$ – Mr.Wizard Mar 7 '17 at 6:23
Plot[x, {x, 0, 1}, Frame -> True, PlotRangePadding -> 0]

Mathematica graphics

The key to the solution was PlotRangePadding -> 0.

| improve this answer | |
  • $\begingroup$ Whoops, I missed that. I was looking for options relating to Frame. Thanks! $\endgroup$ – Will Vousden Jan 31 '13 at 13:21
  • 1
    $\begingroup$ @Will I understand; there are a lot of options, especially for plotting and graphics. $\endgroup$ – Mr.Wizard Jan 31 '13 at 13:29
  • $\begingroup$ PlotRangePadding->0 did not quite eliminate the white space in my ContourPlot and StreamPlot, but PlotRangePadding->-0.02 did. $\endgroup$ – Sander Heinsalu Apr 18 '17 at 0:39
  • $\begingroup$ @Sander That's a bit unexpected in the case of ContourPlot; which version are you using, and is it with every plot or specific code? StreamPlot does seem to leave some extra space so a negative padding value makes more sense there. $\endgroup$ – Mr.Wizard Apr 18 '17 at 6:20
  • $\begingroup$ @Mr.Wizard You are right, the ContourPlot on its own does not leave white space with 0 padding. The white space on it was due to overlaying with the previous StreamPlot using Show[]. I guess it inherited the StreamPlot's padding. $\endgroup$ – Sander Heinsalu Apr 20 '17 at 1:52

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.