Is there a way to explicitly choose which edges of the bounding box to show when plotting something with Boxed->True?

For instance, a plot like

Plot3D[Sin[Pi*x]*Sin[2 Pi*y], {x, 0, 1}, {y, 0, 1}]

returns the image

Example plot

and I would like to remove the three edges of the box which go over the plot, but keep all others.

How can this be done? The documentation does not seem to mention any option which would allow it.

Update: The undocumented Mathematica setting

Boxed -> {Back, Bottom, Left}

is the easiest solution. See my answer below.

  • 2
    $\begingroup$ Does this question help? $\endgroup$
    – Virgil
    Apr 22, 2015 at 19:24
  • $\begingroup$ @Virgil It is a possible solution, but the end result is pretty ugly. I've edited in an example use of FaceGrids. $\endgroup$
    – sps
    Apr 22, 2015 at 20:57

3 Answers 3


I am answering my own question as I have discovered an undocumented Mathematica feature which does exactly what I wanted.

While playing around with some plot options, I discovered that setting


had precisely the effect that I wanted - it displayed only some of the edges of the box. So I started digging, and running

Charting`ResolvePlotTheme["Monochrome", Plot3D]

I noticed something surprising in the options for the theme... namely the setting:

Boxed -> {Back, Bottom, Left}

This is the kind of intuitive and easy solution that I would have expected Mathematica to have from the beginning, but it doesn't seem to be mentioned anywhere in the documentation.

Example of what it does:

 Plot3D[Sin[Pi*x]*Sin[2 Pi*y], {x, 0, 1}, {y, 0, 1}, Boxed -> {Back, Bottom, Left}]

Plot with Boxed setting

I hope this helps someone else with this problem!

  • $\begingroup$ Fantastic discovery! $\endgroup$
    – Taiki
    Apr 27, 2015 at 22:03

If you use Mathematica 10:

plotrange = {{0, 1}, {0, 1}, {-1, 1}};
edges = Composition[
  Part[#, {8, 7, 4, 6, 2, 10, 9, 5, 1, 3, 11, 12}] &,
  Delete[#, List /@ {1, 5, 6, 9, 11, 15}] &,
  MeshPrimitives[#, 1] &,
    Sin[Pi*x]*Sin[2 Pi*y],
    {x, 0, 1},
    {y, 0, 1},
    Axes -> True,
    AxesLabel -> {x, y, z},
    Boxed -> False,
    BoxRatios -> {2, 2, 1},
    PlotRange -> plotrange
    edges[[{3, 4, 7, 8, 11, 12}]]


Edges indices have been set as follows:


  • 1
    $\begingroup$ Fantastic! This works perfectly. $\endgroup$
    – sps
    Apr 26, 2015 at 9:39

Well, if you don't want to use FaceGrids (which can be pretty ugly), you could construct the box you want by hand:

With[{xi = 0, xf = 1, yi = 0, yf = 1, zmin = -1, zmax = 1},
 Show[Plot3D[Sin[Pi*x]*Sin[2 Pi*y], {x, xi, xf}, {y, yi, yf}, Boxed -> False],
     GrayLevel[0.75], Line[1.02{
       {xi, yi, zmin},
       {xi, yf, zmin},
       {xf, yf, zmin},
       {xf, yf, zmax},
       {xi, yf, zmax},
       {xi, yf, zmin},
       {xi, yf, zmax},
       {xi, yi, zmax},
       {xi, yi, zmin}}]}, Boxed -> False],
   PlotRange -> {{xi, xf}, {yi, yf}, {zmin, zmax}}]


Doing this does require knowledge of the range the z-coordinate will take.


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.