1

I have four plots with one plot having a legend entry. As the legend entry takes the style of the first plot. I have to place it above all other plots. But placing the command above all other plots makes the plot go behind other plots graphically.

How can I order the first plot to be on top of the other plots? As an example I have shown only four plots. There will be many plots, and I don't want to complicate it much with styles.

enter image description here

MWE

\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\begin{filecontents*}{pgfplots.dat}
T   A  B  C
1.42857     6.616   6.697   6.782
1.40845     5.413   5.487   5.564
1.38889     4.544   4.612   4.684
1.36986     3.916   3.982   4.052
1.35135     3.469   3.534   3.603
1.33333     3.158   3.224   3.294
1.31579     2.954   3.022   3.094
1.29870     2.838   2.909   2.983
1.28205     2.795   2.870   2.949
1.26582     2.818   2.898   2.984
1.25000     2.905   2.992   3.085
1.23457     3.057   3.153   3.255
1.21951     3.278   3.385   3.499
1.20482     3.571   3.69    3.816
1.19048     3.922   4.052   4.188
1.17647     4.296   4.433   4.576
1.16279     4.645   4.783   4.927
1.14943     4.921   5.054   5.193
1.13636     5.085   5.208   5.335
1.12360     5.114   5.222   5.333
1.11111     5.007   5.097   5.19
1.09890     4.784   4.858   4.933
1.08696     4.477   4.536   4.596
1.07527     4.121   4.167   4.214
1.06383     3.742   3.778   3.815
1.05263     3.364   3.392   3.42
1.04167     3.001   3.022   3.043
1.03093     2.661   2.677   2.694
1.02041     2.35    2.362   2.375
1.01010     2.069   2.079   2.089
1.00000     1.819   1.827   1.834
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \begin{semilogyaxis}[
        xlabel=x,
        ylabel=y,
        xmin=1.10,
        xmax=1.4,
        ymin=2.0,
        ymax=7.0,
        ]
        \addplot [solid,red,line width = 2.0] coordinates {(1.25,10) (1.25,0.01)};
        \addlegendentry{Case 1}        
        \addplot [smooth,line width = 1.0] table[x=T,y=A,mark=] {pgfplots.dat};
        \addplot [smooth,line width = 1.0] table[x=T,y=B,mark=] {pgfplots.dat};
        \addplot [smooth,line width = 1.0] table[x=T,y=C,mark=] {pgfplots.dat};

    \end{semilogyaxis}
\end{tikzpicture}
\end{document}
  • drawing it last? – percusse Sep 17 '17 at 13:52
  • But then the legend takes the first plot style. – nxkryptor Sep 17 '17 at 13:54
  • 2
    not if you add forget plot to the ones you don't want. Or you can use set layers – percusse Sep 17 '17 at 13:59
  • 1
    @nxkryptor, as an example for set layers have a look at e.g. tex.stackexchange.com/a/350514 – Stefan Pinnow Sep 17 '17 at 14:03
  • I tried the suggested answer. But now the vertical line moves outside the plot. I have updated the question. – nxkryptor Sep 17 '17 at 17:42