6
$\begingroup$
Graphics[{
  Text[
       Style["Jean", 14, Bold, "Helvetica", Black, 
    TextAlignment -> Right],{1, 1}],

  Text[
       Style["Claude", 10, "Helvetica", Bold, Black, 
       TextAlignment -> Right], {19, .8}]},

 PlotRange -> {{0, 21}, {0, 2}}, ImageSize -> 300,
 Method -> {"ShrinkWrap" -> True},
 ImagePadding -> 2,
 ImageMargins -> 0]

enter image description here

Now if i just try to add a small Rectangle[], the Text[] disappear.

Graphics[{
  Rectangle[{18, 0}, {20, 2}],
  Text[
       Style["Jean", 14, Bold, "Helvetica", Black, 
    TextAlignment -> Right],{1, 1}],

  Text[
       Style["Claude", 10, "Helvetica", Bold, Black, 
       TextAlignment -> Right], {19, .8}]},

 PlotRange -> {{0, 21}, {0, 2}}, ImageSize -> 300,
 Method -> {"ShrinkWrap" -> True},
 ImagePadding -> 2,
 ImageMargins -> 0]

enter image description here

$\endgroup$
0

2 Answers 2

11
$\begingroup$

If you take out Method -> {"ShrinkWrap" -> True} it works as I think you expect.

$\endgroup$
3
  • $\begingroup$ +1 for pointing this out. I realized after I posted my answer that I didn't know why the leftmost part of the image was disappearing. Thanks! $\endgroup$
    – Cassini
    Feb 16, 2012 at 5:40
  • $\begingroup$ @FJRA,Thank You it works, can you explain ? I use the "ShrinkWrap" to export with any borders. In this case I would like the text on a transparent BackGround. $\endgroup$
    – 500
    Feb 16, 2012 at 5:43
  • 1
    $\begingroup$ To export with a transparent background you can add the Background -> None option: Export["file.png", g, Background -> None] $\endgroup$
    – FJRA
    Feb 16, 2012 at 6:18
5
$\begingroup$

The text doesn't disappear, you're just not seeing it. Try the following mod to your code:

Graphics[{Red, Rectangle[{18, 0}, {20, 2}], 
Text[Style["Jean", 14, Red, Bold, "Helvetica", Black, 
TextAlignment -> Right], {1, 1}], 
Text[Style["Claude", 10, "Helvetica", Bold, Black, 
TextAlignment -> Right], {19, .8}]}, 
PlotRange -> {{0, 21}, {0, 2}},
Frame -> Automatic,
ImageSize->Large,
ImageSize -> 300, Method -> {"ShrinkWrap" -> True}, 
ImagePadding -> 2, ImageMargins -> 0]

Here's what you'll see:

enter image description here

So Claude is just hidden by your black rectangle. Jean is far to the left of your rectangle.

$\endgroup$
2
  • $\begingroup$ Thank You but I dont want the frame. Frame->None` and I am back in Trouble. $\endgroup$
    – 500
    Feb 16, 2012 at 5:41
  • $\begingroup$ As FJRA suggested, you should delete Method ->{"ShrinkWrap" -> True} $\endgroup$
    – Cassini
    Feb 16, 2012 at 5:43

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.