9

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

Will Vousden
  • 767
  • 1
  • 4
  • 16

1 Answers1

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

Mathematica graphics

The key to the solution was PlotRangePadding -> 0.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • Whoops, I missed that. I was looking for options relating to Frame. Thanks! – Will Vousden Jan 31 '13 at 13:21
  • 1
    @Will I understand; there are a lot of options, especially for plotting and graphics. – Mr.Wizard Jan 31 '13 at 13:29
  • PlotRangePadding->0 did not quite eliminate the white space in my ContourPlot and StreamPlot, but PlotRangePadding->-0.02 did. – Sander Heinsalu Apr 18 '17 at 00:39
  • @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. – Mr.Wizard Apr 18 '17 at 06:20
  • @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. – Sander Heinsalu Apr 20 '17 at 01:52