2

I made a code to display curves, here is the code:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\pgfplotstableread[col sep=comma]{
       
       -1.00000000e+00,  1.00000000e+00, -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,  5.91648918e+01
       -1.57894737e-01,  1.00000000e+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, -2.35859076e+00
        6.84210526e-01,  1.00000000e+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, -1.17793423e+01
        1.52631579e+00,  1.00000000e+00, -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, -1.86599894e+00
        2.36842105e+00,  1.00000000e+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,  6.68195573e+00
        3.21052632e+00,  1.00000000e+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,  5.23419032e+00
        4.05263158e+00,  1.00000000e+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, -2.77047418e+00
        4.89473684e+00,  1.00000000e+00,  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.82406447e+00
        5.73684211e+00,  1.00000000e+00,  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,  3.56505451e+01
        6.57894737e+00,  1.00000000e+00,  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,  1.49299632e+02
       
       
}\loadedtable

\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xmin=-0.75,  xmax=11,
ymin=-75,  ymax=85,
axis on top,
xtick distance=1,
ytick distance=10,
tick label style={font=\footnotesize, inner sep=1pt, fill=white},
no marks, samples=15, smooth,
every axis plot post/.append style={very thick}
                ]
\addplot table[x index=0,y index=1] {\loadedtable}node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{0}(x)$};
\addplot table[x index=0,y index=2] {\loadedtable}node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{1}(x)$};
\addplot table[x index=0,y index=3] {\loadedtable}node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{2}(x)$};
\addplot table[x index=0,y index=4] {\loadedtable}node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{3}(x)$};
\addplot table[x index=0,y index=5] {\loadedtable}node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{4}(x)$};
\end{axis}
\end{tikzpicture}


\end{document}

the result

enter image description here

but as you see, what is written is not well organized. As a result, I want a design like the design below.

enter image description here

An idea please.

3
  • 1
    Hi! Have you tried tweaking the xmin, xmax, ymin, and ymax arguments of your axis environment? To better reflect your desired output, it looks like they should be set to the following: xmin=-0.6, xmax=6.6, ymin=-31, ymax=26 along with your ticks set to: xtick={-0.5,0,...,6.5}, ytick={-25,-20,...,20}. As for the positioning of the names, just tweak the pos argument of each node according to your liking. Commented Dec 16, 2023 at 4:37
  • 1
    I would also remove the very thick at least for now as it just makes it harder to see what needs changing.
    – cfr
    Commented Dec 16, 2023 at 5:30
  • How I can organize the naming of each graph ?
    – Karim
    Commented Dec 16, 2023 at 12:19

1 Answer 1

1

Here I demonstrate 2 options for you:

  • using legend entries
  • positioning the text node in plot-coordinates

For the legend entries I set the x-max to a higher value, to avoid overlap with the curves. There are certainly more ways to place it. The entries are defined in the axis-pramble. (See ch. Axis Description/Legends in the pgfplots manual)

For the direct placement it's not along the curve (using pos), which would place it like you've shown, but using axis cs: to the right (assuming the brown curve matches said description). Because the length of the text varies, it's best to specify the west-side anchor of the node, rather than its center. (See nodes features in the pgfmanual)

result

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\pgfplotstableread[col sep=comma]{
       
       -1.00000000e+00,  1.00000000e+00, -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,  5.91648918e+01
       -1.57894737e-01,  1.00000000e+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, -2.35859076e+00
        6.84210526e-01,  1.00000000e+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, -1.17793423e+01
        1.52631579e+00,  1.00000000e+00, -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, -1.86599894e+00
        2.36842105e+00,  1.00000000e+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,  6.68195573e+00
        3.21052632e+00,  1.00000000e+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,  5.23419032e+00
        4.05263158e+00,  1.00000000e+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, -2.77047418e+00
        4.89473684e+00,  1.00000000e+00,  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.82406447e+00
        5.73684211e+00,  1.00000000e+00,  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,  3.56505451e+01
        6.57894737e+00,  1.00000000e+00,  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,  1.49299632e+02
       
       
}\loadedtable

 \begin{tikzpicture}
  \begin{axis}[
    axis lines=center,
    xmin=-0.75,  xmax=18,
    ymin=-75,  ymax=85,
    axis on top,
    xtick distance=1,
    ytick distance=10,
    tick label style={font=\footnotesize, inner sep=1pt, fill=white},
    no marks, samples=15, smooth,
    every axis plot post/.append style={very thick},
    legend entries={
        $Q^{1/2,1/2,5}_{1}(x)$,
        $Q^{1/2,1/2,5}_{2}(x)$  
    },
   ]
    \addplot table[x index=0,y index=1] {\loadedtable};
%                                   node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{0}(x)$};
    \addplot table[x index=0,y index=2] {\loadedtable};
                                    %node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{1}(x)$};
    \addplot table[x index=0,y index=3] {\loadedtable};%node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{2}(x)$};
    \addplot table[x index=0,y index=4] {\loadedtable} node[anchor=west] at (axis cs:7.5,20) {$Q^{1/2,1/2,5}_{3}(x)$};
    \addplot table[x index=0,y index=5] {\loadedtable};%node [pos=0.3, below right] {$Q^{1/2,1/2,5}_{4}(x)$};
  \end{axis}
 
 \end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .