I would like to change the font size of labels next to points in pgfplots.

As an answer to my previous question I got the following MWE:



  axis x line=bottom,
  axis y line=left,
  xmin=0, xmax=2.5,
  ymin=0, ymax=2.5,
  xlabel=position $x$,
  ylabel=time $t$,

  \addplot [only marks,mark=*,nodes near coords={\labelz},
            visualization depends on={value \thisrowno{2}\as\labelz}] 
  table[header=false] {
   0.5 1 a
   1.5 1 f
   0.5 2 g
   1.5 2 z


This works as expected and gives the following result: result of MWE

In my real document, the label texts are much longer and don't properly fit in the graph. Now I would like to use a smaller font size for the labels. How can I achieve that?

----- EDIT -----

The solution suggested in the comment by LaRiFaRi (add the option every node near coord/.append style={font=\tiny} to axis) works, but the result doesn't look very pretty. Here are two screenshots of my graph:

Normal font size:

normal size

Tiny font size:

tiny size

I think the problem is that I use math mode in the label texts.

  • add the option every node near coord/.append style={font=\tiny} to your axis.
    – LaRiFaRi
    Sep 1, 2015 at 13:31
  • @BlubBla, for type of your labels you need to use math environments for labels. For better looking of your image it is simple to narrow, or you need to thing about to change labels -- make them narrowed, for example, something like $E(a_1,b_1)$ etc and in legend explain meaning of $a_i$ and $b_i$.
    – Zarko
    Sep 1, 2015 at 14:22


Browse other questions tagged .