0

I'm trying to add text to my diagram. I tried it with \node, but it doesn't work. What I exactly want to do is, to add concrete numbers of Personalstärke at each coordinate in the diagram. This is how my diagram looks like:

\begin{figure}[h!]

\centering

\begin{tikzpicture}

\pgfplotsset{width=12cm,compat=1.9}

\begin{axis}[

title={},
axis lines = left,
xlabel={Jahr},
x tick label style={/pgf/number format/.cd,%
      scaled y ticks = false,
      set thousands separator={},
      fixed},
ylabel={Personalstärke},
y tick label style={/pgf/number format/.cd,%
      scaled y ticks = false,
      set thousands separator={.},
      fixed},
xmin=2008, xmax=2018,
ymin=12000, ymax=13200,
xtick={0, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018},
ytick={0, 12200, 12400, 12600, 12800, 13000, 13200},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,

]

\addplot[

color=blue,
mark=circle,
]
coordinates {
(2009,12288)(2010,12433)(2011,12522)(2012,12526)(2013,12416)(2014,12782)(2015,12758)(2016,12813)(2017,12920)(2018,13087)
};


\end{axis}

\end{tikzpicture}

\caption[Personalentwicklung{Personalentwicklung}

\label{fig:Personalstarke}

\end{figure}

Can someone help me please?

TobiBS
  • 5,240
  • \node is the way to go, but you need coordinates. For example at (axis cs: 2009,12288) will place the text at the first point, but you need to be inside the axis environment and it helps to offset the text using [above] or [left] etc. – John Kormylo Aug 05 '20 at 14:03
  • If I understand correctly, this is what nodes near coords is for, so try \addplot[nodes near coords, .... – Torbjørn T. Aug 05 '20 at 14:18
  • @JohnKormylo: I tried \node[below] at (2009,12288) { text } and I put it before \end{axis} but it didn't work....can't compile it... – qu33ristan Aug 05 '20 at 15:01
  • @TorbjørnT. nodes near coords works, but how can I edit the numbers there (I would like to make them smaller, different color, decide myself if above or below, set thousandpoint)... Do you know that? – qu33ristan Aug 05 '20 at 15:05
  • For example nodes near coords style={red, font=\tiny}. I don't understand exactly what you mean by "set thousandpoint". Here is a method for setting the position of the labels on a per-point basis: https://tex.stackexchange.com/a/47692/ – Torbjørn T. Aug 05 '20 at 15:16
  • as each node is in a different position, I am using now \node. Somehow it is working now. But thank you guys anyway! – qu33ristan Aug 05 '20 at 15:51
  • compilation errors often mean missing semicolons. – John Kormylo Aug 05 '20 at 22:36

0 Answers0