3
$\begingroup$

I've got this plot for instance.

Plot[x, {x, 0, 5}, Frame -> True]

how can I insert a text on the axis, for exapmple between 1 and 2 I want to write "a"

like this:

enter image description here

This is the new problem:

$\endgroup$
2
  • $\begingroup$ Possible duplicate of 145368. $\endgroup$
    – Syed
    Commented Nov 26, 2023 at 16:35
  • $\begingroup$ thanks. couldn't use that $\endgroup$
    – li xu
    Commented Nov 26, 2023 at 18:04

2 Answers 2

3
$\begingroup$

another possibility

p = Plot[x, {x, 0, 5}, Frame -> True, PlotRangeClipping -> False, 
  ImagePadding -> 20, 
  Epilog -> Style[Text["Tid", {1.5, -.35}, {0, 1}], Red]]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thanks very much. it works well. problem solved $\endgroup$
    – li xu
    Commented Nov 26, 2023 at 18:08
2
$\begingroup$
Plot[x, {x, 0, 5},
 Frame -> True,
 FrameTicks ->
  {{Automatic, None}, {{1, {1.5, "a"}, 2, 3, 4, 5}, None}}]

enter image description here

With some styling options:

Plot[x, {x, 0, 5},
 Frame -> True,
 FrameTicks ->
  {{Automatic, None}, {{1, {1.5, Style["a", Bold, Blue, 14]}, 2, 3, 4, 5}, None}},
 GridLines -> {Range[5], Automatic}]

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ Notice that with this method, the minor ticks on the axes are now lost. $\endgroup$
    – Nasser
    Commented Nov 26, 2023 at 16:43
  • 1
    $\begingroup$ Good observation - I didn't notice that $\endgroup$
    – eldo
    Commented Nov 26, 2023 at 16:45
  • $\begingroup$ thanks very much. $\endgroup$
    – li xu
    Commented Nov 26, 2023 at 17:56

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.