Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to label a 2D plot with something like $A/B$ rather than $\frac{A}{B}$. I have tried:

Plot[Sin[x], {x, 0, 10}, AxesLabel -> {HoldForm[A/B], y}]

However, this leaves the $x$-axis as $\frac{A}{B}$. Any ideas?

share|improve this question
up vote 2 down vote accepted

Use InputForm:

Plot[Sin[x], {x, 0, 10}, AxesLabel -> {InputForm[A/B], y}]

Or just string:

Plot[Sin[x], {x, 0, 10}, AxesLabel -> {"A/B", y}]

You can also wrap these things in Style to get further:

Plot[Sin[x], {x, 0, 10}, AxesLabel -> {Style["A/B", 18, Bold, FontFamily -> "Georgia"], y}] 
share|improve this answer
String works perfectly. I actually needed something in the form of $A/B_C$, which didn't render correctly with InputForm. Thanks. – cosmoguy Nov 26 '12 at 3:00

If you would like to get a display along the lines of the $\LaTeX$ command \nicefrac (with a shifted baseline for the numerator and denominator), you could do the following:

niceFrac[x_, y_] := 
  RowBox[{AdjustmentBox[HoldForm[x], BoxBaselineShift -> -.5], "/", 
    AdjustmentBox[HoldForm[y], BoxBaselineShift -> .5]}]]
SetAttributes[niceFrac, HoldAll]

Plot[Sin[x], {x, 0, 10}, AxesLabel -> {niceFrac[A, B], y}]


What I did in the function niceFrac is to give the first argument a nudge upward, and the second argument an equal downward push relative to the / symbol. This may be a useful compromise when you don't want to be completely one-dimensional but also don't want to waste too much space with the stacked fraction.

I added the HoldAll attribute only to allow you to typeset more complicated expressions that you don't want to evaluate (could be left out).

share|improve this answer

Your Answer


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.