Skip to main content
deleted 12 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]π}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: Using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]π}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]π}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: Using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 π}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: Using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 π}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 π}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

deleted 42 characters in body
Source Link
Eli Lansey
  • 7.6k
  • 3
  • 36
  • 73

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: This is similar to Szabolcs's answer, but usingUsing scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: This is similar to Szabolcs's answer, but using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: Using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics

Source Link
Eli Lansey
  • 7.6k
  • 3
  • 36
  • 73

You can use the Prolog option with Scaled coordinates:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}
]

Mathematica graphics

Note: This is similar to Szabolcs's answer, but using scaled coordinates lets this work for any PlotRangePadding, and with PlotRangePadding->False:

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> .6]

Mathematica graphics

Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True, 
 Prolog -> {LightGray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}, 
 PlotRangePadding -> -.2, PlotRangeClipping -> False]

Mathematica graphics