8
$\begingroup$

I am trying to add some ticks but I would like the default ticks on the $x$-axis to keep appearing. If I use the following they vanish:

Plot[x, {x, 0, 4}, Ticks -> {{Pi, 2}, Automatic}]

enter image description here

$\endgroup$

1 Answer 1

9
$\begingroup$

With

plot = Plot[x, {x, 0, 4}]

based on this answer:

ticks = Charting`FindTicks[{0, 1}, {0, 1}] @@ PlotRange[plot][[1]];
newticks = {{Pi, Pi}}~Join~ticks;
Show[plot, Ticks -> {newticks, Automatic}]

enter image description here

$\endgroup$
6
  • $\begingroup$ could you edit it including new ticks also along the y-axis, such as Pi? $\endgroup$
    – Andrea G
    Commented May 7, 2017 at 11:01
  • 1
    $\begingroup$ @AndreaG That's easy and you can do it yourself: change [[1]] to [[2]], make some newticks2 like in the answer, and do Ticks -> {newticks, newticks2}. $\endgroup$
    – corey979
    Commented May 7, 2017 at 11:30
  • $\begingroup$ what if I wanted only those new ticks to be red? $\endgroup$
    – Andrea G
    Commented Nov 27, 2017 at 21:01
  • 1
    $\begingroup$ Replace {Pi, Pi} with {Pi, Style[Pi, Red]}. $\endgroup$
    – corey979
    Commented Nov 27, 2017 at 22:32
  • $\begingroup$ in this case it seems to me that only the text Pi gets red, but not the tick. Do you have any further suggestion? $\endgroup$
    – Andrea G
    Commented Nov 28, 2017 at 12:59

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.