Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm attempting to display the geometric meaning of a contour integralenter image description here

but as you can see, the typesetting of the contour integral (created via the Epilog function) looks awful because the contour integral is too high relative to the integrand. In addition, the text is too small. How can this be fixed? My code for this figure is

a = 1.5;
b = 1;
RegionPlot[
    q^2/a^2 + p^2/b^2 <= 1, {q, -a - .1, a + .1}, {p, -b - .1, b + .1},
    AspectRatio -> Automatic,
    Axes -> True,
    AxesLabel -> {q, p},
    Frame -> False,
    PlotStyle -> Directive[Green, Opacity[0.9]],
    Ticks -> False,
    Epilog -> {Text["\[ContourIntegral]p\[DifferentialD]q", 
    Offset[{0, 0}, {.7, .35}]]},
    ColorFunction -> "Pastel"]
share|improve this question
    
The text looks fine when rendered on my screen. It looks like you are exporting this to generate this image, to what format are you exporting? –  Guillochon Mar 10 '13 at 2:45
3  
"looks awful... How can this be fixed?" — You should be more explicit in why you think the typesetting is awful and what how you want it to look like, else we'll only be wasting our time guessing how to make it less "awful to you" when we don't know why. Is it the kerning? Is it the $\mathbf{d}$? Is it the spacing? Is it the baseline alignment? Is it the colour?... –  rm -rf Mar 10 '13 at 2:52
    
possible duplicate of Fixing quirky typesetting in plot labels –  Jens Mar 10 '13 at 3:40
    
wow, that is hideous (it's not anti-aliased) –  amr Mar 10 '13 at 5:41
add comment

3 Answers

up vote 6 down vote accepted

Not sure if this is what you mean, but a FormBox might work:

a = 1.5;
b = 1;
RegionPlot[
 q^2/a^2 + p^2/b^2 <= 1, {q, -a - .1, a + .1}, {p, -b - .1, b + .1}, 
 AspectRatio -> Automatic, Axes -> True, AxesLabel -> {q, p}, 
 Frame -> False, PlotStyle -> Directive[Green, Opacity[0.9]], 
 Ticks -> False, 
 Epilog -> {Text[
     Style["\!\(\*FormBox[\(\[ContourIntegral]\\\ p\\\ \[DifferentialD]q\),
TraditionalForm]\)", Magnification -> 2], 
    Offset[{0, 0}, {.7, .35}]]}, ColorFunction -> "Pastel",
 BaseStyle -> Large]

formbox

To see how I entered the integral correctly, follow my answer to "Formula Formatting is Small and Chunky" where I show a movie of how to enter formatted matter into a TraditionalForm command - but in your case replace TraditionalForm by the Text command instead.

share|improve this answer
    
(+1) back at you. It's always good to know multiple ways to do the same thing! –  Xerxes Mar 10 '13 at 3:59
    
This is great! Your help is much appreciated. –  Nick Thompson Mar 10 '13 at 4:41
add comment

The reason it looks so bad is that you are using a String instead of a mathematical expression. Unfortunately, ContourIntegral does not have a built-in display form, so we need to build one first.

MakeBoxes[ContourIntegral[expr_, var_], form_] := 
 RowBox[{"\[ContourIntegral]", 
   RowBox[{MakeBoxes[expr, form], 
     RowBox[{"\[DifferentialD]", MakeBoxes[var, form]}]}]}]

It would also help to make the text a bit bigger, which I've done with Style:

a = 1.5;
b = 1;
RegionPlot[
 q^2/a^2 + p^2/b^2 <= 1, {q, -a - .1, a + .1}, {p, -b - .1, b + .1}, 
 AspectRatio -> Automatic, Axes -> True, AxesLabel -> {q, p}, 
 Frame -> False, PlotStyle -> Directive[Green, Opacity[0.9]], 
 Ticks -> False, 
 Epilog -> {Text[Style[\[ContourIntegral]p \[DifferentialD]q, 16], 
    Offset[{0, 0}, {.7, .35}]]}, ColorFunction -> "Pastel"]

Contour Integral

share|improve this answer
    
Posted simultaneously, it seems (+1). –  Jens Mar 10 '13 at 3:58
    
Thanks! I really like this solution! –  Nick Thompson Mar 10 '13 at 4:09
    
I would guess you are not using V9. This doesn't work there. –  m_goldberg Mar 10 '13 at 6:46
    
@m_goldberg I'm not sure if an expression not having a built-in 2d form counts as a bug, but I gave the necessary code to add one above. –  Xerxes Mar 10 '13 at 7:10
    
See my answer. Your example behaves the same as my first example in V9. –  m_goldberg Mar 10 '13 at 7:12
add comment

Normally I would say that your mistake was passing a string as the first argument of text, but in this case there is a problem in V9.0.1 with passing the contour integral expression directly.

You should be able to do it this way.

With[{a = 1.5, b = 1},
  RegionPlot[
    q^2/a^2 + p^2/b^2 <= 1, {q, -a - .1, a + .1}, {p, -b - .1, b + .1}, 
    AspectRatio -> Automatic,
    Axes -> True,
    AxesLabel -> {q, p},
    Frame -> False,
    Ticks -> False,
    ColorFunction -> "Pastel",
    Epilog -> {Text[\[ContourIntegral]p \[DifferentialD]q,  Offset[{0, 0}, {.7, .35}]]}]]

Note the lacke of quotes around \[ContourIntegral]p \[DifferentialD]q.

But that doesn't work because the conversion to traditional form promised by the Mathematica documentation is not made.

enter image description here

I think this is a bug because

With[{a = 1.5, b = 1},
  RegionPlot[
    q^2/a^2 + p^2/b^2 <= 1, {q, -a - .1, a + .1}, {p, -b - .1, b + .1}, 
    AspectRatio -> Automatic,
    Axes -> True,
    AxesLabel -> {q, p},
    Frame -> False,
    Ticks -> False,
    ColorFunction -> "Pastel",
    Epilog -> {Text[\[Integral]f[x] \[DifferentialD]x,  Offset[{0, 0}, {.7, .35}]]}]]

works as expected.

enter image description here

Note

Jens' method of using a FormBox does work in V9.0.1.

Update

I brought this to the attention of WRI technical support. Their reply was almost a verbatim quote Jen's answer.

share|improve this answer
    
I wonder if it's a good thing that WRI support consider our site authoritative, or bad that it seems to be so difficult to coax them into giving any more information than we already know (and that one can quickly find on one's own rather than e-mailing support)? –  Oleksandr R. Mar 14 '13 at 23:03
    
@OleksandrR. If my understanding of SE's goals is correct, this should be considered an achievement. –  m_goldberg Mar 15 '13 at 13:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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