1

Anyway to dynamically / automatically label all points with point value (tikzpicture graf / plot)?

\begin{tikzpicture}
\begin{axis}
    [
    ,width=15cm
    ,xlabel={Gjennomsnittlig lengde verdi for 10 nivåer}
    ,ylabel=Lengde verdi
    ,xtick=data,
   %,xtick={0,1,...,3}
    ,xticklabels={Nivå 1,Nivå 2,Nivå 3,Nivå 4,Nivå 5,Nivå 6,Nivå 7,Nivå 8,Nivå 9,Nivå 10}
    ]

    \addplot+[sharp plot] coordinates
    { (0,62.37)(1,64.77)(2,67.39)(3,70.18)(4,73.33)(5,76.64)(6,80.43)(7,84.40)(8,89.03)(9,94.29)};
\end{axis}
\end{tikzpicture}
3
  • nodes near coords? – user121799 May 1 '18 at 11:31
  • yes but i would have to do it for each cord, was hoping there was a less time consuming way, as this is only one of many plots im doing. – Melvin Langvik May 1 '18 at 11:34
  • @marmot i misunderstood your comment, thanks! – Melvin Langvik May 1 '18 at 12:10
4

foreach can understand (some) patterns if supplied appropriately. Here you can use

xticklabels={Nivå 1,Nivå ...,Nivå 10}

and for the labels nodes near coords uses automatically point values by default

\begin{tikzpicture}
\begin{axis}
    [
    ,width=15cm
    ,xlabel={Gjennomsnittlig lengde verdi for 10 nivåer}
    ,ylabel=Lengde verdi
    ,xtick=data,
   %,xtick={0,1,...,3}
    ,xticklabels={Nivå 1,Nivå ...,Nivå 10},
nodes near coords
    ]
    \addplot+[sharp plot] coordinates
    { (0,62.37)(1,64.77)(2,67.39)(3,70.18)(4,73.33)(5,76.64)(6,80.43)(7,84.40)(8,89.03)(9,94.29)};
\end{axis}
\end{tikzpicture}

enter image description here

1
  • Exactly what i was looking for! :) Thanks a bunch – Melvin Langvik May 1 '18 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.