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:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
xmin=0, xmax=2.5,
ymin=0, ymax=2.5,
xtick=\empty,
ytick=\empty,
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
};
\end{axis}
\end{tikzpicture}
\end{document}
This works as expected and gives the following result:
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:
Tiny font size:
I think the problem is that I use math mode in the label texts.
every node near coord/.append style={font=\tiny}
to youraxis
.$E(a_1,b_1)$
etc and in legend explain meaning of$a_i
$ and$b_i$
.