SHARE
TWEET

Untitled

a guest Jul 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. documentclass{article}
  2. usepackage{tikz}
  3. usepackage{pgfplots}
  4. pgfplotsset{compat=1.12}
  5. usepackage{pgfplotstable}
  6. usetikzlibrary{shapes.geometric, arrows,calc,decorations,decorations.pathreplacing,
  7. patterns,angles,quotes,intersections}
  8.  
  9. begin{filecontents*}{data.txt}
  10.                    x                    y
  11.                    1                    2
  12.                    2                    4
  13.                    3                    6
  14.                    4                    8
  15.                    5                   10
  16.                    6                   12
  17.                    7                   14
  18.                    8                   16
  19.                    9                   18
  20.                   10                   20
  21.                   20                   20
  22. end{filecontents*}
  23. usepackage{calculator}
  24. LOG[10]{2.999}{loga}
  25. LOG[10]{5.001}{logb}
  26. begin{document}
  27.  
  28. pgfplotstableread{data.txt}IGAIEdata
  29. pgfplotstableset{
  30.     create on use/nepw_mod/.style={
  31.         create col/copy column from table={data.txt}{nepw}
  32.     }
  33. }
  34. begin{tikzpicture}
  35.     begin{loglogaxis}[
  36.         xlabel={$omega$},
  37.         ylabel={Relative error},
  38.         log basis x=10,
  39.         /pgf/number format/precision=5
  40.         ]
  41. %       addplot[draw=none,forget plot] table[header=true,skip coords between index={0}{2}, skip coords between index={5}{12},
  42. %y={create col/linear regression}]{data.txt} coordinate [pos=0] (A) coordinate [pos=1] (B);
  43.  
  44.         addplot[draw=none,forget plot] table[header=true, restrict x to domain=loga:logb,
  45.              y={create col/linear regression={y=y}}]{data.txt} coordinate [pos=0] (A) coordinate [pos=1] (B);
  46. %            
  47. %       addplot[draw=none,forget plot] table[header=true,skip first n=3,
  48. %            y={create col/linear regression}]{data.txt} coordinate [pos=0] (A) coordinate [pos=1] (B);
  49.  
  50.         xdefslopea{pgfplotstableregressiona}
  51.         draw (A) |- (B) node [pos=0.25,anchor=east]{pgfmathprintnumber{slopea}};
  52.         addplot[green,mark=*] table{data.txt};
  53.         addplot table[restrict x to domain=loga:logb]{data.txt};
  54.     end{loglogaxis}
  55. end{tikzpicture}
  56. end{document}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top