5
$\begingroup$

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

$\endgroup$
7
  • $\begingroup$ This seems like a bug. Try Grid[{{Graphics[Disk[{0, 0}, Scaled[.1]]]}}, Background -> LightBlue]. It comes out white, but if you move the cursor up, it becomes blue. I assume you don't want Rasterize? $\endgroup$
    – Stitch
    May 12, 2017 at 14:55
  • $\begingroup$ This also seems platform dependent. I get different results on Windows using 11.1.0. $\endgroup$
    – chuy
    May 12, 2017 at 17:02
  • $\begingroup$ @Stitch Correct. I do not want Rasterize. $\endgroup$
    – Edmund
    May 12, 2017 at 17:07
  • $\begingroup$ Reported to WRI. CASE:3890272 $\endgroup$
    – Edmund
    May 12, 2017 at 20:46
  • 1
    $\begingroup$ Somewhat related: (22279), (83190), (85521) $\endgroup$
    – Mr.Wizard
    May 13, 2017 at 2:04

2 Answers 2

4
$\begingroup$

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:

$\endgroup$
3
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ I will report to WRI. $\endgroup$
    – Edmund
    May 12, 2017 at 19:27
  • 2
    $\begingroup$ 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. $\endgroup$
    – Edmund
    May 12, 2017 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.