# Placing labels with a rotation angle

To place the labels "m = 2", "p = 3" and "m + p = 2 + 3" as in the attached figure, I made some tests but the result is not yet the one expected. Is there a more rigorous method ?

  \documentclass[border=10pt]{standalone}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\usepackage{pgfplots}
\usepackage{mathrsfs}
\pgfplotsset{compat=1.16}
\usetikzlibrary{intersections}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
xtick={0,1,...,7},ytick={0,1,...,6},
ymin=-2.5,ymax=7,xmin=-1,xmax=8,
ymin=-2.5,
axis on top=false,
enlargelimits=false,
axis x line=middle,
axis y line=middle,
tick align=outside,
tickwidth=0.12cm,
xticklabels={0,1,\empty,\empty,\empty,\empty,\empty},
yticklabels={0,1,\empty,\empty,\empty,\empty},
major tick style = {thick, black},
axis line style = ultra thick,
x tick label style={
/pgf/number format/1000 sep={}
},
extra x ticks={8},
extra x tick label={\null},
extra y ticks={7},
extra y tick label={\null},
extra tick style={tick style={draw=none}},
xlabel=,ylabel=,
every axis x label/.style=
{
at={(ticklabel* cs:1)},
anchor=west
},
every axis y label/.style=
{
at={(ticklabel* cs:1)},
anchor=south
},
>=stealth,
grid=none]

mark=+,
only marks,
mark options={thick,black}
]
coordinates
{(0,1) (1,1.3) (2,1.69) (3,2.197) (4,2.8561) (5,3.71293) (6,4.826809) (7,6.2748517) (8,8.157307209)};

\draw[black,->,thick] (2,0)-- node[above,rotate=90]{$u_2$} (2,1.69);
\draw[black,->,thick] (3,0)-- node[above,rotate=90]{$u_3$} (3,2.197);
\draw[black,->,thick] (5,0)-- node[above,rotate=90]{$u_2 \times u_3$}(5,3.71293);

\node[below,black,rotate=45] at (2,-0.4){$m=2$};
\node[below,black,rotate=45] at (3,-0.4){$p=3$};
\node[below,black,rotate=45] at (4,-0.8){$m+p=2+3$};
\node[right,black] at (6,4.826809) {$\mathcal{C}_{u_n}$};
\node[below left=2pt] at (0,0){$0$};

\end{axis}
\end{tikzpicture}
\end{document}


You only have to replace below by anchor=north east, then you can use the coordinates in a much more intuitive way.

  \documentclass[border=10pt]{standalone}
%  \usepackage{unicode-math}
%   \setmainfont{XITS}
%   \setmathfont{XITS Math}
\usepackage{pgfplots}
\usepackage{mathrsfs}
\pgfplotsset{compat=1.16}
%   \usetikzlibrary{intersections}
%   \usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
xtick={0,1,...,7},ytick={0,1,...,6},
ymin=-2.5,ymax=7,xmin=-1,xmax=8,
ymin=-2.5,
axis on top=false,
enlargelimits=false,
axis x line=middle,
axis y line=middle,
tick align=outside,
tickwidth=0.12cm,
xticklabels={0,1,\empty,\empty,\empty,\empty,\empty},
yticklabels={0,1,\empty,\empty,\empty,\empty},
major tick style = {thick, black},
axis line style = ultra thick,
x tick label style={
/pgf/number format/1000 sep={}
},
extra x ticks={8},
extra x tick label={\null},
extra y ticks={7},
extra y tick label={\null},
extra tick style={tick style={draw=none}},
xlabel=,ylabel=,
every axis x label/.style=
{
at={(ticklabel* cs:1)},
anchor=west
},
every axis y label/.style=
{
at={(ticklabel* cs:1)},
anchor=south
},
>=stealth,
grid=none]

mark=+,
only marks,
mark options={thick,black}
]
coordinates
{(0,1) (1,1.3) (2,1.69) (3,2.197) (4,2.8561) (5,3.71293) (6,4.826809) (7,6.2748517) (8,8.157307209)};

\draw[black,->,thick] (2,0)-- node[above,rotate=90]{$u_2$} (2,1.69);
\draw[black,->,thick] (3,0)-- node[above,rotate=90]{$u_3$} (3,2.197);
\draw[black,->,thick] (5,0)-- node[above,rotate=90]{$u_2 \times u_3$}(5,3.71293);

\node[anchor=north east,black,rotate=45] at (2,-0.1){$m=2$};
\node[anchor=north east,black,rotate=45] at (3,-0.1){$p=3$};
\node[anchor=north east,black,rotate=45] at (5,-0.1){$m+p=2+3$};
\node[right,black] at (6,4.826809) {$\mathcal{C}_{u_n}$};
\node[below left=2pt] at (0,0){$0$};

\end{axis}
\end{tikzpicture}
\end{document}


If you're not actually using the extra ticks for anything, you could do

extra x ticks={2,3,5},
extra x tick labels={$m=2$,$p=3$,$m+p=2+3$},
extra x tick style={
ticklabel style={rotate=45,anchor=north east}
},


instead of those nodes. 

\documentclass[border=10pt]{standalone}
%\usepackage{unicode-math}
%\setmainfont{XITS}
%\setmathfont{XITS Math}
\usepackage{pgfplots}
%\usepackage{mathrsfs}
\pgfplotsset{compat=1.16}
\usetikzlibrary{intersections}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
xtick={0,1,...,7},
ytick={0,1,...,6},
ymin=-2.5,ymax=7,xmin=-1,xmax=8,
ymin=-2.5,
axis on top=false,
enlargelimits=false,
axis x line=middle,
axis y line=middle,
tick align=outside,
tickwidth=0.12cm,
xticklabels={0,1},
yticklabels={0,1},
major tick style = {thick, black},
axis line style = ultra thick,
x tick label style={
/pgf/number format/1000 sep={}
},
extra x ticks={2,3,5},
extra x tick labels={$m=2$,$p=3$,$m+p=2+3$},
extra x tick style={
ticklabel style={rotate=45,anchor=north east}
},
extra y ticks={7},
extra y tick label={\null},
extra tick style={tick style={draw=none}},
xlabel=,ylabel=,
every axis x label/.style=
{
at={(ticklabel* cs:1)},
anchor=west
},
every axis y label/.style=
{
at={(ticklabel* cs:1)},
anchor=south
},
>=stealth,
grid=none
]

mark=+,
only marks,
mark options={thick,black}
]
coordinates
{(0,1) (1,1.3) (2,1.69) (3,2.197) (4,2.8561) (5,3.71293) (6,4.826809) (7,6.2748517) (8,8.157307209)};

\draw[black,->,thick] (2,0)-- node[above,rotate=90]{$u_2$} (2,1.69);
\draw[black,->,thick] (3,0)-- node[above,rotate=90]{$u_3$} (3,2.197);
\draw[black,->,thick] (5,0)-- node[above,rotate=90]{$u_2 \times u_3$}(5,3.71293);

\node[right,black] at (6,4.826809) {$\mathcal{C}_{u_n}$};
\node[below left=2pt] at (0,0){$0$};

\end{axis}
\end{tikzpicture}
\end{document}
`