2
$\begingroup$

This works well:

Plot[x, {x, 0, 1}, Epilog -> Text[1/2, {1/2, 0.1}]]

This doesn't (the "1/2" label is not visible):

Plot[x, {x, 0, 1}, Epilog -> Text[1/2, {1/2, -0.1}]]

What is the easiest solution?

$\endgroup$
5
$\begingroup$
Plot[x, {x, 0, 1}, Epilog -> Text[1/2, {1/2, -0.1}], 
  ImagePadding -> {{Automatic, Automatic}, {Scaled[.04], Automatic}}]

enter image description here

$Version

"12.0.0 for Linux x86 (64-bit) (April 7, 2019)"

Front-End: Wolfram Cloud.

Note: in version 9.0, you also need to add PlotRangeClipping -> False.

Update: An alternative approach using Ticks:

Plot[x, {x, 0, 1}, 
 Ticks -> {Append[Charting`ScaledTicks["Linear"][##], 
   {.5, Framed[ToString[1/2, StandardForm], FrameStyle -> Opacity[0]], {0, 0}}] &, 
   Automatic}]

enter image description here

$\endgroup$
  • $\begingroup$ Mathematica 12 gives using 'Plot[x, {x, 0, 1}, Epilog -> Text[1/2, {1/2, -0.1}], ImagePadding -> {{Automatic, Automatic}, {Scaled[.1], Automatic}}]' a result which has only number "1" visible from the fraction "1/2". How to fix that? $\endgroup$ – wondering Oct 22 at 10:59
  • $\begingroup$ I am actually not even able to reproduce your result, neither in Mathematica 11, nor Mathematica 12. $\endgroup$ – wondering Oct 22 at 11:10
  • $\begingroup$ @wondering, it is probably OS-related then (I don't have access to version 11; but it works in version 12.0 Wolfram Cloud Front-End). You might want to add the version/OS information in your post. $\endgroup$ – kglr Oct 22 at 11:18
  • 1
    $\begingroup$ With v12 under macOS 10.15, the PlotRangeClipping -> False is needed along with ImagePadding -> {{Automatic, Automatic}, {Scaled[.06], Automatic}} $\endgroup$ – Bob Hanlon Oct 22 at 14:32
  • 1
    $\begingroup$ Are you trying to label the graph, or instead just add a tick mark? $\endgroup$ – David G. Stork Oct 22 at 17:49
0
$\begingroup$

This probably isn't the best solution but could be handy at times.

Labeled[Plot[x, {x, 0, 1}], 1/2]

PLot with label

However, I should also mention that the label is not a part of the graphics.

$\endgroup$

Your Answer

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

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