1

I am trying to move the two lines with the 2 and the 3 on top down, so that this line connects with the top left corner of the y-axis. Somehow it doesn't move. I know that the scaling is weird and probably the reason for the whole mess, yet I need it for the proper scaling in my document.

\documentclass[letter,11pt,twoside]{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}


\begin{center}
\begin{tikzpicture}[scale=0.90,
  labelnode/.style={font=\footnotesize, above},
  labelline/.style={stealth-stealth,shorten >=0.1pt, shorten <=0.5pt}
]
\begin{axis}[
    axis lines = left,
    xlabel = $\beta$,
    ylabel = {$E\left[\pi_B^D\right]$},
    width=16cm,
    height=8cm,
    xmin=2, xmax=8.2, ymin=340, ymax=480,
xtick={2,3,4,5,6,7,8},
xticklabels={2,3,4,5,6,7,8},
]
\addplot [
    domain=2 : 5.587,
    samples=100,
    color=red     ] {275 + 50 * 10^(2/3) * (1/x)^(2/3)} ;
\coordinate (l) at (rel axis cs:0,1);
\path (-10, 1000 |- l) coordinate (aux1)
(318, 1000 |- l)  coordinate (aux2)
(550, 1000 |- l) coordinate (aux3);
\end{axis}
\draw [labelline] (aux1) -- node[labelnode]{$2$} (aux2);
\draw [labelline] (aux2) -- node[labelnode]{$3$} (aux3);
\end{tikzpicture}
\end{center}

\end{document}

Thank you in advance

Bernard
  • 271,350
Paul
  • 551
  • 2
  • 8

1 Answers1

0

You are using the old compatibility mode and add scale=0.9 to the options of the tikzpicture. If you switch to a newer version, you do no longer need axis cs:. And instead of scale you can adjust the width and height of the plot to decrease the size of the plot, scale in an ambient tikzpicture confuses pgfplots .

\documentclass[letter,11pt,twoside]{book}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}


\begin{center}
\begin{tikzpicture}[
  labelnode/.style={font=\footnotesize, above},
  labelline/.style={stealth-stealth,shorten >=0.1pt, shorten <=0.5pt}
]
\begin{axis}[
    axis lines = left,
    xlabel = $\beta$,
    ylabel = {$E\left[\pi_B^D\right]$},
    width=16cm,
    height=8cm,
    xmin=2, xmax=8.2, ymin=340, ymax=480,
xtick={2,3,4,5,6,7,8},
xticklabels={2,3,4,5,6,7,8},
]
\addplot [
    domain=2 : 5.587,
    samples=100,
    color=red     ] {275 + 50 * 10^(2/3) * (1/x)^(2/3)} ;
\coordinate (l) at (rel axis cs:0,1);
\path (2,0 |- l) coordinate (aux1)
 (5,0 |- l)  coordinate (aux2)
 (8,0 |- l) coordinate (aux3);
\end{axis}
\draw [labelline] (aux1) -- node[labelnode]{$2$} (aux2);
\draw [labelline] (aux2) -- node[labelnode]{$3$} (aux3);
\end{tikzpicture}
\end{center}
\end{document}

enter image description here