1

Hello fellows and folks!

Could you give me a hint/hand with this plot? Then I can use it as a template for further plots :)

I have the y coordinates, they are like 25 values. But the x coordinates were generated with python list comp. e.g. [i for i in np.argange(0,202,2)]. How can I deal with that here? So far, I have found this, but I don't know how generate the "x" coordinates.

\begin{tikzpicture} 
\begin{loglogaxis}[ xlabel={Degrees of freedom}, 
                    ylabel={$L_2$ Error} ] 


\addplot coordinates { (5,8.312e-02) (17,2.547e-02)  
                      (49,7.407e-03) (129,2.102e-03) 
                      (321,5.874e-04) (769,1.623e-04)
                       (1793,4.442e-05) 
                       (4097,1.207e-05) (9217,3.261e-06) }; 



\addplot coordinates{  (7,8.472e-02) 
                      (31,3.044e-02)
                      (111,1.022e-02) 
                      (351,3.303e-03) 
                      (1023,1.039e-03)
                      (2815,3.196e-04)
                      (7423,9.658e-05) 
                      (18943,2.873e-05) (47103,8.437e-06) }; 



\addplot coordinates{ (9,7.881e-02)
         (49,3.243e-02) (209,1.232e-02) 
           (769,4.454e-03) (2561,1.551e-03) 
            (7937,5.236e-04) (23297,1.723e-04) 
              (65537,5.545e-05) (178177,1.751e-05) }; 



\addplot coordinates{ (11,6.887e-02)
                       (71,3.177e-02)
                       (351,1.341e-02) (1471,5.334e-03)
                     (5503,2.027e-03) (18943,7.415e-04)
                    (61183,2.628e-04) 
                   (187903,9.063e-05) (553983,3.053e-05) }; 



\addplot coordinates{ (13,5.755e-02) 
                     (97,2.925e-02) (545,1.351e-02)
                     (2561,5.842e-03) (10625,2.397e-03)
                       (40193,9.414e-04) (141569,3.564e-04)
                     (471041,1.308e-04) (1496065,4.670e-05) }; 

\legend{$d=2$,$d=3$,$d=4$,$d=5$,$d=6$} \end{loglogaxis} 

\end{tikzpicture}

I really appreciate it!

enter image description here

I'm having trouble with the labels:

\begin{axis}[xlabel={Degrees of freedom},
                    axis lines=middle,
                    grid=major,
                    grid style={dashed},
ymax=0.99,xmax=200]

enter image description here

3
  • 1
    Use pgfplots or the datavisualization library.
    – user121799
    Commented May 5, 2019 at 21:42
  • @marmot I have the y coordinates, they are like 15 values. But the x coordinates were generated with python list comp. e.g. [i for i in np.argange(0,202,2)]. How can I deal with that here?
    – NaveganTeX
    Commented May 5, 2019 at 21:48
  • 1
    x expression=\coordindex*<something>. If you want a more concrete answer, consider making the question more concrete.
    – user121799
    Commented May 5, 2019 at 21:51

1 Answer 1

4
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{pypythongeneratedyvalues.txt}
Y
8.312
2.547
7.407
2.102
5.874
1.623
4.442
1.207
3.261
\end{filecontents*}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,grid=major,grid style={dashed},
ymax=9,xmax=900]
 \addplot table[x expr=100*\coordindex,y=Y]{pypythongeneratedyvalues.txt};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

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