I am using pgfplots to plot simple functions. For example,

\addplot[color=black] coordinates {

I want to add a letter, say "x", at the point 0.5 on the horizontal axis to make some emphasis. Anyone knows how to do this?

  • Do you just want the letter "x", or do you also want to draw a vertical line or something like that? Should the letter be aligned like the tick numbers, or should it be inside the axis?
    – Jake
    Jun 22, 2013 at 21:45
  • @Jake I think it would be better to put the letter inside the axis, because sometimes this emphasis might coincide with the original labels.
    – Richie
    Jun 22, 2013 at 22:38

1 Answer 1


You can use the extra ... options:

extra x ticks={0.5},
extra x tick labels={$x$},

enter image description here


  • As per Qrrbrbirlbel's suggestion, the extra tick labels are now aligned with the other labels.
  • As requested in the comments I have added multiple extra tick marks.



  extra x ticks={0.1,0.5,0.7},
  extra x tick labels={$x$,$y$,$z$},
  extra x tick style={%
     text height=\heightof{0},% Align labels at baseline
\addplot[color=black] coordinates {
  • Can we align the x to the baselines from the other ticks? extra x tick style={text height=\heightof{0}} is one way, but not very nice. Jun 22, 2013 at 22:40
  • @PeterGrill Thanks a lot. But if I want to add two or more labels, I tried that extra x ticks={0.1,0.5,0.7}, extra x tick labels={$x$,$y$,$z$} does not work. Do you know how to do this?
    – Richie
    Jun 22, 2013 at 22:40
  • @Qrrbrbirlbel: Good point, but I was not able to find another way to do that. Jun 22, 2013 at 22:54
  • @Richie: Have updated solution to show that it can be extended to multiple labels. Perhaps you are using an older release. I am using the latest version in TeXLive2012. Jun 22, 2013 at 22:55
  • 1
    @LeonMeier: No, it's a new syntax. It's explained in pages 937 and 938 from pgfmanual.pdf. height("0") gives you the height of whatever is inside quotes. Similar functions are depth and width.
    – Ignasi
    Mar 10, 2017 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .