0
$\begingroup$

This question already has an answer here:

jerry = {
    Graphics[Line[{ {11,7} , {9,6} , {8,6} , {7.5,6.5} , {8,12} , {9,12} , {9.5,11.5} , {10,12} , {10.5,12} , {11,11} , {11,7} }]],
    Graphics[Line[{ {9,13} , {8.5,13} , {7.5,14} , {8,14} , {9,13.5} , {9,13} }]],
    Graphics[Line[{ {8.5,13} , {7.5,13} , {6.5,14.5} , {7,14.5} , {8.5,13} }]],
    Graphics[Line[{ {9,13} , {9.5,14.5} , {9,14.5} , {9,13} }]],
    Graphics[Line[{ {9,15} , {9,15.5} , {8.5,15.5} , {8.5,15} , {9,15} }]],
    Graphics[Line[{ {9.5,14.5} , {9.5,15.5} , {8,15.5} , {8,15} , {7,15.5} , {7,15} , {8,14.5} , {9.5,14.5} }]],
    Graphics[Line[{ {9,16} , {9,16.5} , {8.5,16.5} , {8.5,16} , {9,16} }]],
    Graphics[Line[{ {9,16.5} , {9,16.5} , {8.5,17.5} , {8.5,16.5} }]],
    Graphics[Line[{ {8,16} , {8,16.5} , {7.5,16.5} , {7.5,16} , {8,16} }]],
    Graphics[Line[{ {8,16.5} , {8,17.5} , {7.5,17.5} , {7.5,16.5} }]],
    Graphics[Line[{ {9,13} , {6,13} , {5,13.5} , {3.5,16.5} , {3.5,17} , {4,17} , {4,18} , {2,19} , {5,18.5} , {6,19} , {6.5,20} , {6.5,19} , {8,19.5} , {7,19} , {7.5,19} , {9,18} , {9.5,16} , {10,16} , {10,15.5} , {9,13} }]],
    Graphics[Line[{ {4,15.5} , {3,15} , {2,15} , {1,16} , {1,18} , {2,19} }]],
    Graphics[Line[{ {7.5,19} , {7.5,21} , {7,21} , {6,20} , {6,19} }]],
    Graphics[Line[{ {9,13} , {14.5,17.5} , {14,18} , {14.5,18.5} , {15,18} , {15.5,18.5} , {16,18.5} , {16.5,18} , {16.5,17.5} , {16,17} , {15,16.5} , {10.5,12} }]],
    Graphics[Line[{ {6,13} , {5,12.5} , {2.5,9} , {2,9} , {2,8} , {3,8} , {3,8.5} , {6,11} , {6.5,10} , {5.5,2} , {4.5,1.5} , {4.5,1} , {5,.5} , {5.5,.5} , {7.5,5} , {8.5,5.5} , {8.5,2.5} , {9.5,2} , {10.5,2.5} , {9.5,3} , {9.5,4} , {11,7} }]],
    Graphics[Line[{ {6.5,17.5} , {6.5,18} , {7,18} }]],
    Graphics[Line[{ {9,15} , {12,16} }]],
    Graphics[Line[{ {9,15.5} , {12,17} }]],
    Graphics[Line[{ {8,15} , {4,14} }]],
    Graphics[Line[{ {8,14.5} , {4,13}}]]
};




blankDo[name_,xmin_,xmax_,ymin_,ymax_] := blank[name] = 
Graphics[
    GridLines -> {Range[xmin,xmax], Range[ymin,ymax]}, 
    GridLinesStyle -> {{Opacity[1/2], LightGray, Dashed}, {Opacity[1/2], LightGray, Dashed}}, 
    PlotRange -> {{xmin-0.2,xmax+0.2}, {ymin-0.2,ymax+0.2}}, 
    AxesStyle -> {{LightGray, Dashed}, {LightGray, Dashed}}, 
    Frame -> True,
    FrameTicks -> {Range[xmin,xmax], Range[ymin,ymax]}, 
    ImageSize -> Full
];
blankDo["jerry",0,17,0,22];
blankDo["cartoon_character_A",0,17,0,22];
blankDo["cartoon_character_B",0,17,0,22];
blankDo["cartoon_character_C",0,17,0,22];
blankDo["cartoon_character_D",0,17,0,22];


Show[jerry, blank["jerry"]]

Does not get a combined graph, while Show[blank["jerry"]] and Show[jerry] works fine seperately.

I am using multiple Graphics[Line[{}]] so that I can check each segments later. blankDo creates each blank template for drawing and I am hoping Show[jerry, blank["jerry"]] will show both the picture and the template.

What's the shortest way to fix it? (keeping most of the structure of these codes)

$\endgroup$

marked as duplicate by Kuba Aug 11 '18 at 6:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Does changing Graphics[GridLines -> .., ..] to Graphics[{}, GridLines->.., ..] help? $\endgroup$ – Carl Woll Aug 10 '18 at 19:52
  • $\begingroup$ First change: You need only one call to Line (put all line segments within a single call). $\endgroup$ – David G. Stork Aug 10 '18 at 19:58
  • 1
    $\begingroup$ One thing to remember is that Show takes options from the first graphics object, which means that you have to write Show[blank["jerry"], jerry] and not Show[jerry, blank["jerry"]]. Otherwise the option values for the grid lines etc. will be the default values. Also, you need to make the change Carl recommended. With those two changes it will work. $\endgroup$ – C. E. Aug 10 '18 at 20:23
  • $\begingroup$ @C.E. Worked like a magic! All sorted. $\endgroup$ – Chen Stats Yu Aug 10 '18 at 20:52
  • $\begingroup$ @ChenStatsYu since that was the issue I marked it as a duplicate of a generic topic for future readers. $\endgroup$ – Kuba Aug 11 '18 at 7:00
1
$\begingroup$

As suggested in comments,

blankDo[name_,xmin_,xmax_,ymin_,ymax_] := blank[name] = 
Graphics[{},
    GridLines -> {Range[xmin,xmax], Range[ymin,ymax]}, 
    GridLinesStyle -> {{Opacity[1/2], LightGray, Dashed}, {Opacity[1/2], LightGray, Dashed}}, 
    PlotRange -> {{xmin-0.2,xmax+0.2}, {ymin-0.2,ymax+0.2}}, 
    AxesStyle -> {{LightGray, Dashed}, {LightGray, Dashed}}, 
    Frame -> True,
    FrameTicks -> {Range[xmin,xmax], Range[ymin,ymax]}, 
    ImageSize -> Full
];

together with

Show[blank["jerry"], jerry]

worked perfectly!

$\endgroup$

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