1
$\begingroup$

I make a Graphics and then add Text[Style["b",size] to it. When changing the size, I noticed that the overall graphics gets cropped by large amount when the size is set to some specific value. For example, changing the size from 15 to 16 in this example below.

Here is the MWE

Clear[x, y]
a = 4;
b = 2;
Graphics[
 {
  First@ContourPlot[x^2/a^2 - y^2/b^2 == 1, {x, -6, 6}, {y, -3, 3}],
  Text[Style["b", 15], {-a, b/2}, {1, -1}]
  },
 PlotRange -> All, Axes -> True, AspectRatio -> Automatic
 ]

Mathematica graphics

Now I changed the size of "b" in the above to 16 and this is the result

Mathematica graphics

The same problem when the size is 17 and 18. But when the size is 19, it become normal again. This is below is the same code as above, but size set to 19

Mathematica graphics

The strange thing, is that if I put the "b" in different locations, I do not see this effect. Here is "b" with size 16, but on the right side

Clear[x, y]
a = 4;
b = 2;
Graphics[
 {
  First@ContourPlot[x^2/a^2 - y^2/b^2 == 1, {x, -6, 6}, {y, -3, 3}],
  Text[Style["b", 16], {a, b/2}, {1, -1}]  (*different location*)
  },
 PlotRange -> All, Axes -> True, AspectRatio -> Automatic
 ]

and this shows ok

Mathematica graphics

The plot gets cropped only when I move "b" to the other location (and may be some other locations, did not check) and when using some specific size (in this example it was 16,17 and 18)

Here is a display showing range of sizes. Notice the size=16,17,18 in this

plot[s_Integer] := Module[{a = 4, b = 2, x, y},
  Labeled[Graphics[
    {
     First@ContourPlot[x^2/a^2 - y^2/b^2 == 1, {x, -6, 6}, {y, -3, 3}],
     Text[Style["b", s], {-a, b/2}, {1, -1}]
     },
    PlotRange -> All, Axes -> True
    ]
   , Row[{"size ", s}]
   ]
  ]
 Grid[Partition[plot[#] & /@ {13, 14, 15, 16, 17, 18, 19, 20, 21}, 3], 
   Spacings -> {1, 1}, Frame -> All]

Mathematica graphics

This below is the same run as above, just put the "b" on different location. Changed the line Text[Style["b", s], {-a, b/2}, {1, -1}] to Text[Style["b", s], {a, b/2}, {1, -1}] in the above function. Now the problem do not show up:

Mathematica graphics

Any explanation for this result? What is special about those sizes? and the location? I am using V 9.01 on windows 7, 64 bit

$\endgroup$
  • $\begingroup$ +1 for such an example-ridden question. I look forward to the answers... $\endgroup$ – ciao Feb 7 '14 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.