I am drawing several diagrams like the following one:
I would like to label the important points with $P_1$
, $P_2$
and so on. The problem is that there is no global position for the node
s that fits for all.
I don't want that the label to cover the diagram line.
- Is there a clever way to avoid that?
- Can I have a fourth column (s, F, Label and Position) with N(orth), W(est), S(outh) and E(ast) for example?
- Have you a good idea?
Here's my code so far:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
enlargelimits = true,
xlabel = {Travel $s$ in mm},
ylabel = {Force $F$ in N},
width =120mm,
height= 80mm,
title = {Force-Travel-Diagram},
]
\addplot[
line width=1pt,
mark=*,
x=s,
y=F,
nodes near coords,
point meta=explicit symbolic,
nodes={font=\small},
nodes near coords align={anchor=west},
] table
[
row sep=\\,
meta=Label
]
{
s F Label\\
0 0 {$P_0$}\\
0.03 2 {$P_1$}\\
0.7 6 {$P_2$}\\
0.71 5 {$P_3$}\\
1.4 12 {$P_4$}\\
};
\end{axis}
\end{tikzpicture}
\end{document}