1
$\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$
3
$\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$
  • $\begingroup$ could you edit it including new ticks also along the y-axis, such as Pi? $\endgroup$ – Andrea G May 7 '17 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 May 7 '17 at 11:30
  • $\begingroup$ what if I wanted only those new ticks to be red? $\endgroup$ – Andrea G Nov 27 '17 at 21:01
  • 1
    $\begingroup$ Replace {Pi, Pi} with {Pi, Style[Pi, Red]}. $\endgroup$ – corey979 Nov 27 '17 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 Nov 28 '17 at 12:59

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.