5

I have plots with custom PlotMarkers that I need to display in a Grid with other information. When the Grid is given a Background option

  • The custom PlotMarkersare given the Grid background and it over prints other markers
  • The axis labels and plot area are given the Grid background even if an explicit Background option has been given for the plot.

Plot outside of the grid

p =
 ListPlot[{{{1, 1}}, {{2, 1}}, {{3, 1}}},
  PlotMarkers -> Graphics /@ {
     Circle[{0, 0}, Scaled[.1]],
     Disk[{0, 0}, Scaled[.1]],
     Disk[{0, 0}, Scaled[.1], {0, 4}]},
  ImageSize -> Small]

Mathematica graphics

Plot in a Grid with Background option

Grid[{{p}},
 Background -> LightBlue]

Mathematica graphics

Here the markers have been given the Grid Background option. Their background also over prints adjacent markers.

Plot with Background option in a Grid with Background option

Grid[{{Show[p, Background -> Pink]}},
 Background -> LightBlue]

Mathematica graphics

The horror! Even by explicitly setting the plot's Background option Grid still hijacks the background.

How do I stop Grid Background from overriding both the plot's and the custom PlotMarkers backgrounds?

Version 11.1.0 with Win 7 Ent

CASE:3890272

Edmund
  • 42,267
  • 3
  • 51
  • 143

2 Answers2

4

I find that often Pane is effective in preserving the size and style of Graphics that are undesirably changed.

gp = Pane @ Show[p, Background -> Pink];

Grid[{{gp, Spacer[0]}, {Spacer[0], gp}}, Background -> LightBlue]

enter image description here

Other examples:

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
3

What you have encountered looks like a bug to me. You might use GraphicsGrid as a work-around.

plot =
  ListPlot[{{{1, 1}}, {{2, 1}}, {{3, 1}}},
    PlotRangePadding -> {{Scaled[.15], Scaled[.15]}, Automatic},
    PlotMarkers -> 
      Graphics /@ 
        {Circle[{0, 0}, Scaled[.1]], 
         Disk[{0, 0}, Scaled[.1]], 
         Disk[{0, 0}, Scaled[.1], {0, 4}]},
   Background -> Pink,
   ImageSize -> Small]

plot

Grid[{{plot, " "}, {" ", plot}}, Background -> LightBlue]

grid

But with GraphicsGrid

GraphicsGrid[{{plot, " "}, {" ", plot}}, Background -> LightBlue]

ggrid

Edmund
  • 42,267
  • 3
  • 51
  • 143
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • I will report to WRI. – Edmund May 12 '17 at 19:27
  • 2
    GraphicsGrid is not viable since the grid has formatted text and makes good use of a few of the formatting options. I have discovered that I can wrap the plots in a Pane or Panel to protect the backgrounds. – Edmund May 12 '17 at 20:49