4
$\begingroup$

I use this command

Grid[{
  {1, 2},
  {Graphics[{Blue, Disk[], Text[Style["1", Large, Red]]}],
   Graphics[{Blue, Disk[], Text[Style["2", Large, Red]]}]}
  }, Background -> LightGray]

enter image description here

But I don't want grid's background setting to affect the number in graphics, like the graphics blow. What should I do?

enter image description here

$\endgroup$
1
  • $\begingroup$ this issue seems to be version/os related. It does not arise in version 12.0 (Wolfram Cloud). Which version/os are you using? $\endgroup$
    – kglr
    Commented Mar 4, 2020 at 15:58

2 Answers 2

5
$\begingroup$

Specifying Background -> None at the right place in the Graphics body works in version 10.1:

Grid[{{1, 2}, 
  Graphics[{Blue, Disk[], Background -> None, 
      Text[Style[#, Large, Red]]}] & /@ {"1", "2"}}, Background -> LightGray]

enter image description here

$\endgroup$
3
  • $\begingroup$ I put "Background -> None" in the end of Graphics and in Text won't work. Can I ask why put "Background -> None" in the middle solve my problem in the most easy way? Thank you very much. $\endgroup$
    – pmzhu
    Commented Mar 4, 2020 at 18:45
  • 1
    $\begingroup$ @pmzhu In the manner I used it Background -> None needs to come before the Text expressions, just like Blue needs to come before Disk[]. You could also use the more specific {Background -> None, Text[. . .]} should this conflict with some other part of the graphics. $\endgroup$
    – Mr.Wizard
    Commented Mar 4, 2020 at 18:50
  • $\begingroup$ That is a very clear explanation, now I understand why. Thank you. $\endgroup$
    – pmzhu
    Commented Mar 4, 2020 at 19:22
1
$\begingroup$
Maybe this will be a solution:

diskTable[colDisk_: Blue, colText_: Red, colBack_: LightGray, 
   sizeDisk_Integer: 250, textSize_Integer: 24, numDisk_Integer: 2] :=
   Block[{i = 1}, 
   Row[Table[
     Column[{Style[i, textSize - 10, colText], 
       Graphics[{colDisk, Disk[], 
         Text[Style[i++, textSize, colText]]}, 
        ImageSize -> sizeDisk]}, Alignment -> Center], numDisk], 
    Frame -> True, FrameStyle -> colBack, Background -> colBack]];

diskTable[]
$\endgroup$

Your Answer

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

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