범례 항목 사용

범례 항목 사용

곡선을 표시하는 코드를 만들었습니다. 코드는 다음과 같습니다.

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{amsmath} 
\pgfplotsset{compat=1.18}
\usepackage{xcolor}
\begin{document}
\pgfplotstableread[col sep=comma]{
       -1.00000000e+00,  1.00000000e+00, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  7.35937500e+01, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  1.23005515e+02
       -5.78947368e-01,  1.00000000e+00, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  3.17518749e+01, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  5.91648918e+01
       -1.57894737e-01,  1.00000000e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  7.79163062e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  1.93708181e+01
        2.63157895e-01,  1.00000000e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -3.42580172e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -2.35859076e+00
        6.84210526e-01,  1.00000000e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -6.28491883e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -1.12508974e+01
        1.10526316e+00,  1.00000000e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -4.41589541e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -1.17793423e+01
        1.52631579e+00,  1.00000000e+00, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -6.94584190e-01, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -7.66284401e+00
        1.94736842e+00,  1.00000000e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00,  2.75748416e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00, -1.86599894e+00
        2.36842105e+00,  1.00000000e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  4.57310099e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  3.40091845e+00
        2.78947368e+00,  1.00000000e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  4.13937964e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  6.68195573e+00
        3.21052632e+00,  1.00000000e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  1.59775549e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  7.27548248e+00
        3.63157895e+00,  1.00000000e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00, -2.15601404e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00,  5.23419032e+00
        4.05263158e+00,  1.00000000e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00, -5.47184956e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00,  1.36509289e+00
        4.47368421e+00,  1.00000000e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -5.94534961e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -2.77047418e+00
        4.89473684e+00,  1.00000000e+00,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.17790734e-01,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.85685319e+00
        5.31578947e+00,  1.00000000e+00,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00,  1.50238725e+01,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00, -1.82406447e+00
        5.73684211e+00,  1.00000000e+00,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  4.50470077e+01,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  1.01521937e+01
        6.15789474e+00,  1.00000000e+00,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  9.50733043e+01,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  3.56505451e+01
        6.57894737e+00,  1.00000000e+00,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  1.71278774e+02,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  8.00039353e+01
        7.00000000e+00,  1.00000000e+00,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  2.80593750e+02,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  1.49299632e+02 
                
}\loadedtable
\begin{figure}[h]
\tikzset{ellipsenode/.style={draw, ellipse, thick, text width=5ex, align=center, inner sep=2pt}}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.6,  xmax=6.6,
ymin=-17,  ymax=28,
axis on top,
xtick distance=1,
ytick distance=5,
tick label style={font=\footnotesize, inner sep=1pt, fill=white},
no marks, samples=15, smooth,
legend entries={
        $Q^{1/2,1/2,5}_{0}(x)$,
        $Q^{1/2,1/2,5}_{1}(x)$,
        $Q^{1/2,1/2,5}_{2}(x)$,
        $Q^{1/2,1/2,5}_{3}(x)$,
        $Q^{1/2,1/2,5}_{4}(x)$
},                ]
\addplot[color=red] table[x index=0,y index=1] {\loadedtable};
\addplot[color=blue]table[x index=0,y index=2] {\loadedtable};
\addplot[color=green] table[x index=0,y index=3] {\loadedtable};
\addplot[color=purple] table[x index=0,y index=4] {\loadedtable};
\addplot[color=yellow] table[x index=0,y index=5] {\loadedtable};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.6,  xmax=6.6,
ymin=-17,  ymax=28,
axis on top,
xtick distance=1,
ytick distance=5,
tick label style={font=\footnotesize, inner sep=1pt, fill=white},
no marks, samples=15, smooth,
legend entries={
        $Q^{(3)}_{0}(x)$,
        $Q^{(3)}_{1}(x)$,
        $Q^{(3)}_{2}(x)$,
        $Q^{(3)}_{3}(x)$,
        $Q^{(3)}_{4}(x)$
},    
   ]
\addplot[color=red] table[x index=0,y index=1] {\loadedtable};
\addplot[color=blue]table[x index=0,y index=6] {\loadedtable};
\addplot[color=green] table[x index=0,y index=7] {\loadedtable};
\addplot[color=purple] table[x index=0,y index=8] {\loadedtable};
\addplot[color=yellow] table[x index=0,y index=9] {\loadedtable};
\end{axis}
\end{tikzpicture}
\caption{Graph of $Q^{1/2,1/2,5}_n$ and $Q^{(3)}_n$ for $n = 0, 1, 2, 3, 4$}
\end{figure}
\end{document}

결과

여기에 이미지 설명을 입력하세요

하지만 컴파일 결과에서는 두 설명 테이블이 그래프를 더 잘 볼 수 있을 만큼 작게 만들고 싶습니다. 아이디어 부탁드립니다

답변1

Wrt.링크가 포함된 내 댓글여기에 자신만의 범례를 디자인하거나 조판하는 방법이 있습니다. 차이점을 더 잘 확인하고 혼란을 피하기 위해 별도의 답변으로 설정했습니다.

결과가 더 작음

비고

전문

디자인을 위해서는 class 를 사용하는 것이 더 좋습니다 standalone. 필요에 따라 "용지" 크기에 맞게 조정되기 때문입니다. 여기에는 패키지가 xcolor필요하지 않습니다. matrix범례를 조판하려면 tikzlibrary가 필요합니다 .

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{pgfplots}
\usepackage{amsmath} 
\pgfplotsset{compat=1.18}
%\usepackage{xcolor}    % <<< not needed in pgfplots
\usetikzlibrary{matrix} % <<< to typeset the legend, later

플롯 세트

내장 범례를 사용하지 않으므로 더 이상 사용되지 않습니다.

%    \pgfplotsset{
%       every axis legend/.append style={
%           at={(1.02,1)},
%           anchor=north west,
%       },
%    }

축 환경

  • 제목을 붙이자
  • 모든 범례 설명 제거
  • \label각각 뒤에 추가\addplot ... ;
  • 나중에 사용하기 위해 a를 정의합니다 \coordinate. 여기서는(label)
    \begin{axis}[
        ...
        no marks, samples=15, smooth,
        title=$Q^{1/2,1/2,5}_n(x)$; % <<<
    ]
    % <<< new: put labels, to reference them later ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    \addplot[color=red] table[x index=0,y index=1] {\loadedtable};\label{plot:L1}
    ...
    
    % <<< new: legend will go here, in plot coordinates
    \coordinate (legend) at (.3,25);
    \end{axis}

범례를 조판하세요

기본 구조는 입니다 \matrix[...] at (legend) { ... };. \node원하는 방식으로 보려면 일부 스타일을 정의해야 합니다.

.\matrixLatex table​이것이 바로 & & \\한 데이터 행의 구조를 볼 수 있는 이유입니다. 내부에서는 이전에 설정된 모든 플롯 레이블을 참조하여 일반 텍스트처럼 조판하면 됩니다. 모든 참조와 마찬가지로 변경 사항을 적용한 후 두 번째 컴파일이 필요합니다.

    % ~~~ building your legend using a matrix (it's like a table within Tikz) ~~~~
    \matrix[
        draw,               % to see it, with
        matrix of nodes,    % see manual
        anchor=north west,  % upper left corner
        font={\tiny},       % use smaller font, if you like
    ] at (legend) {
        Index $n$: &&\\
        \ref{plot:L1} 0&\ref{plot:L2} 1&\ref{plot:L3} 2\\
        \ref{plot:L4} 3&\ref{plot:L5} 4&\\
    };  

결과 및 코드

결과

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{pgfplots}
\usepackage{amsmath} 
\pgfplotsset{compat=1.18}
%\usepackage{xcolor}    % <<< not needed in pgfplots
\usetikzlibrary{matrix} % <<< to typeset the legend, later

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
    \pgfplotstableread[col sep=comma]{
           -1.00000000e+00,  1.00000000e+00, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  7.35937500e+01, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  1.23005515e+02
           -5.78947368e-01,  1.00000000e+00, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  3.17518749e+01, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  5.91648918e+01
           -1.57894737e-01,  1.00000000e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  7.79163062e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  1.93708181e+01
            2.63157895e-01,  1.00000000e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -3.42580172e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -2.35859076e+00
            6.84210526e-01,  1.00000000e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -6.28491883e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -1.12508974e+01
            1.10526316e+00,  1.00000000e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -4.41589541e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -1.17793423e+01
            1.52631579e+00,  1.00000000e+00, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -6.94584190e-01, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -7.66284401e+00
            1.94736842e+00,  1.00000000e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00,  2.75748416e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00, -1.86599894e+00
            2.36842105e+00,  1.00000000e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  4.57310099e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  3.40091845e+00
            2.78947368e+00,  1.00000000e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  4.13937964e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  6.68195573e+00
            3.21052632e+00,  1.00000000e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  1.59775549e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  7.27548248e+00
            3.63157895e+00,  1.00000000e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00, -2.15601404e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00,  5.23419032e+00
            4.05263158e+00,  1.00000000e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00, -5.47184956e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00,  1.36509289e+00
            4.47368421e+00,  1.00000000e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -5.94534961e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -2.77047418e+00
            4.89473684e+00,  1.00000000e+00,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.17790734e-01,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.85685319e+00
            5.31578947e+00,  1.00000000e+00,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00,  1.50238725e+01,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00, -1.82406447e+00
            5.73684211e+00,  1.00000000e+00,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  4.50470077e+01,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  1.01521937e+01
            6.15789474e+00,  1.00000000e+00,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  9.50733043e+01,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  3.56505451e+01
            6.57894737e+00,  1.00000000e+00,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  1.71278774e+02,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  8.00039353e+01
            7.00000000e+00,  1.00000000e+00,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  2.80593750e+02,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  1.49299632e+02 
                
}\loadedtable

\tikzset{
    ellipsenode/.style={
        draw, ellipse, thick, text width=5ex, 
        align=center, inner sep=2pt
    }
}

    \begin{tikzpicture}
%    \pgfplotsset{
%       every axis legend/.append style={
%           at={(1.02,1)},
%           anchor=north west,
%       },
%    }
    \begin{axis}[
        axis lines=center,
        xmin=-0.6,  xmax=6.6,
        ymin=-17,  ymax=28,
        axis on top,
        xtick distance=1,
        ytick distance=5,
        tick label style={font=\footnotesize, inner sep=1pt, fill=white},
        no marks, samples=15, smooth,
        title=$Q^{1/2,1/2,5}_n(x)$; % <<<
    ]
    % <<< new: put labels, to reference them later ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    \addplot[color=red] table[x index=0,y index=1] {\loadedtable};\label{plot:L1}
    \addplot[color=blue]table[x index=0,y index=2] {\loadedtable};\label{plot:L2}
    \addplot[color=green] table[x index=0,y index=3] {\loadedtable};\label{plot:L3}
    \addplot[color=purple] table[x index=0,y index=4] {\loadedtable};\label{plot:L4}
    \addplot[color=yellow] table[x index=0,y index=5] {\loadedtable};\label{plot:L5}
    
    % <<< new: legend will go here, in plot coordinates
    \coordinate (legend) at (.3,25);
    \end{axis}
    
    % ~~~ building your legend using a matrix (it's like a table within Tikz) ~~~~
    \matrix[
        draw,               % to see it, with
        matrix of nodes,    % see manual
        anchor=north west,  % upper left corner
        font={\tiny},       % use smaller font, if you like
    ] at (legend) {
        Index $n$: &&\\
        \ref{plot:L1} 0&\ref{plot:L2} 1&\ref{plot:L3} 2\\
        \ref{plot:L4} 3&\ref{plot:L5} 4&\\
    };  
    \end{tikzpicture}
\end{document}

답변2

이를 수행하는 한 가지 방법이 있습니다. 가장 쉬운 방법은 범례를 그림 외부, 즉 오른쪽에 배치하는 것입니다.Ch. "4.9.5 범례 모양"(pdf)또는"20.9 범례 모양"(html)pgfplots-manual에 설명되어 있습니다.

위에 범례를 넣어보았으나 보기에 좋지 않습니다. 또한 해당 장의 첫 번째 페이지에 설명된 접근 방식을 사용하여 자신만의 범례를 Tikz로 그릴 수도 있습니다.

% from said chapter, sth. like this:
 \matrix [style=every axis legend] {
    draw plot specification 1 & \node{legend 1}\\
...

또 다른 대안은 기사에 있는 많은 기능에 대한 약어를 소개하고 이를 플롯과 함께 사용하는 것입니다. 길이가 더 짧으면 두 도면이 게시한 대로 단선 도면에 맞을 수도 있습니다.

귀하의 코드와의 차이점은 두 플롯에 모두 추가한 다음 코드 줄입니다.

  • 축 범례 스타일 지정
  • 매뉴얼에서 (0,0)은 왼쪽 하단, (1,1)은 오른쪽 상단이라는 것을 기억하세요.
  • 범례를 오른쪽 상단으로 약간 이동하여 배치
  • 왼쪽 상단 모서리( north west)를 해당 위치에 고정합니다.
\begin{tikzpicture}
\pgfplotsset{                                 % <<<
    every axis legend/.append style={
        at={(1.02,1)},
        anchor=north west
    },
}
\begin{axis}[

결과

% https://tex.stackexchange.com/questions/705129/using-legend-entries

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{amsmath} 
\pgfplotsset{compat=1.18}
\usepackage{xcolor}
\begin{document}
\pgfplotstableread[col sep=comma]{
       -1.00000000e+00,  1.00000000e+00, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  7.35937500e+01, -3.50000000e+00,         9.75000000e+00, -2.62500000e+01,  1.23005515e+02
       -5.78947368e-01,  1.00000000e+00, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  3.17518749e+01, -3.07894737e+00,         6.97991690e+00, -1.45631652e+01,  5.91648918e+01
       -1.57894737e-01,  1.00000000e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  7.79163062e+00, -2.65789474e+00,         4.56440443e+00, -6.15144336e+00,  1.93708181e+01
        2.63157895e-01,  1.00000000e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -3.42580172e+00, -2.23684211e+00,         2.50346260e+00, -5.66955824e-01, -2.35859076e+00
        6.84210526e-01,  1.00000000e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -6.28491883e+00, -1.81578947e+00,         7.97091413e-01,  2.63817612e+00, -1.12508974e+01
        1.10526316e+00,  1.00000000e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -4.41589541e+00, -1.39473684e+00,        -5.54709141e-01,  3.91183117e+00, -1.17793423e+01
        1.52631579e+00,  1.00000000e+00, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -6.94584190e-01, -9.73684211e-01,        -1.55193906e+00,  3.70188803e+00, -7.66284401e+00
        1.94736842e+00,  1.00000000e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00,  2.75748416e+00, -5.52631579e-01,        -2.19459834e+00,  2.45622540e+00, -1.86599894e+00
        2.36842105e+00,  1.00000000e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  4.57310099e+00, -1.31578947e-01,        -2.48268698e+00,  6.22721971e-01,  3.40091845e+00
        2.78947368e+00,  1.00000000e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  4.13937964e+00,  2.89473684e-01,        -2.41620499e+00, -1.35074355e+00,  6.68195573e+00
        3.21052632e+00,  1.00000000e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  1.59775549e+00,  7.10526316e-01,        -1.99515235e+00, -3.01629246e+00,  7.27548248e+00
        3.63157895e+00,  1.00000000e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00, -2.15601404e+00,  1.13157895e+00,        -1.21952909e+00, -3.92604607e+00,  5.23419032e+00
        4.05263158e+00,  1.00000000e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00, -5.47184956e+00,  1.55263158e+00,        -8.93351801e-02, -3.63212567e+00,  1.36509289e+00
        4.47368421e+00,  1.00000000e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -5.94534961e+00,  1.97368421e+00,         1.39542936e+00, -1.68665257e+00, -2.77047418e+00
        4.89473684e+00,  1.00000000e+00,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.17790734e-01,  2.39473684e+00,         3.23476454e+00,  2.35825193e+00, -4.85685319e+00
        5.31578947e+00,  1.00000000e+00,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00,  1.50238725e+01,  2.81578947e+00,         5.42867036e+00,  8.95046654e+00, -1.82406447e+00
        5.73684211e+00,  1.00000000e+00,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  4.50470077e+01,  3.23684211e+00,         7.97714681e+00,  1.85378700e+01,  1.01521937e+01
        6.15789474e+00,  1.00000000e+00,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  9.50733043e+01,  3.65789474e+00,         1.08801939e+01,  3.15683409e+01,  3.56505451e+01
        6.57894737e+00,  1.00000000e+00,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  1.71278774e+02,  4.07894737e+00,         1.41378116e+01,  4.84897580e+01,  8.00039353e+01
        7.00000000e+00,  1.00000000e+00,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  2.80593750e+02,  4.50000000e+00,         1.77500000e+01,  6.97500000e+01,  1.49299632e+02 
                
}\loadedtable
\begin{figure}[h]
\tikzset{ellipsenode/.style={draw, ellipse, thick, text width=5ex, align=center, inner sep=2pt}}
\begin{tikzpicture}
\pgfplotsset{
    every axis legend/.append style={
        at={(1.02,1)},
        anchor=north west
    },
}
\begin{axis}[
axis lines=center,
xmin=-0.6,  xmax=6.6,
ymin=-17,  ymax=28,
axis on top,
xtick distance=1,
ytick distance=5,
tick label style={font=\footnotesize, inner sep=1pt, fill=white},
no marks, samples=15, smooth,
legend entries={
        $Q^{1/2,1/2,5}_{0}(x)$,
        $Q^{1/2,1/2,5}_{1}(x)$,
        $Q^{1/2,1/2,5}_{2}(x)$,
        $Q^{1/2,1/2,5}_{3}(x)$,
        $Q^{1/2,1/2,5}_{4}(x)$
},                ]
\addplot[color=red] table[x index=0,y index=1] {\loadedtable};
\addplot[color=blue]table[x index=0,y index=2] {\loadedtable};
\addplot[color=green] table[x index=0,y index=3] {\loadedtable};
\addplot[color=purple] table[x index=0,y index=4] {\loadedtable};
\addplot[color=yellow] table[x index=0,y index=5] {\loadedtable};
\end{axis}
\end{tikzpicture}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{tikzpicture}
\pgfplotsset{
    every axis legend/.append style={
        at={(1.02,1)},
        anchor=north west
    },
}
\begin{axis}[
axis lines=center,
xmin=-0.6,  xmax=6.6,
ymin=-17,  ymax=28,
axis on top,
xtick distance=1,
ytick distance=5,
tick label style={font=\footnotesize, inner sep=1pt, fill=white},
no marks, samples=15, smooth,
legend entries={
        $Q^{(3)}_{0}(x)$,
        $Q^{(3)}_{1}(x)$,
        $Q^{(3)}_{2}(x)$,
        $Q^{(3)}_{3}(x)$,
        $Q^{(3)}_{4}(x)$
},    
   ]
\addplot[color=red] table[x index=0,y index=1] {\loadedtable};
\addplot[color=blue]table[x index=0,y index=6] {\loadedtable};
\addplot[color=green] table[x index=0,y index=7] {\loadedtable};
\addplot[color=purple] table[x index=0,y index=8] {\loadedtable};
\addplot[color=yellow] table[x index=0,y index=9] {\loadedtable};
\end{axis}
\end{tikzpicture}
\caption{Graph of $Q^{1/2,1/2,5}_n$ and $Q^{(3)}_n$ for $n = 0, 1, 2, 3, 4$}
\end{figure}
\end{document}

추신:

참고로 범례를 플롯의 상단으로 이동하면 다음과 같은 결과를 얻을 수 있습니다.

결과 2

두 가지 모두에 사용하여:

\pgfplotsset{
    every axis legend/.append style={
        at={(.5,1.03)},
        anchor=south
    },
}

추신 2

title다음은 a를 사용 하고 관련 변경 사항에만 초점을 맞추는 대안입니다 n. 그러나 0, 1, ...만 나열해도 여기에서는 범례가 충분히 작아지지 않습니다.

결과3

\begin{axis}[
    axis lines=center,
    xmin=-0.6,  xmax=6.6,
    ymin=-17,  ymax=28,
    axis on top,
    xtick distance=1,
    ytick distance=5,
    tick label style={font=\footnotesize, inner sep=1pt, fill=white},
    no marks, samples=15, smooth,
    legend entries={
            $n=0$,              % <<<
            $n=1$,
            $n=2$,
            $n=3$,
            $n=4$,
    },
    title=$Q^{1/2,1/2,5}_n(x)$; % <<<
]

관련 정보