Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. %% MWE for SX: Defining variables with numbers taken from a file
  2. documentclass{standalone}
  3.  
  4. usepackage[utf8]{inputenx}
  5. usepackage[T1]{fontenc}
  6. %% Use only sans-serif fonts; change to serif if desired
  7. renewcommand*sfdefault{phv}
  8. renewcommand*{familydefault}{sfdefault}
  9. usepackage{arevmath}
  10.  
  11. usepackage{tikz}
  12. usepackage{pgfplots}
  13. pgfplotsset{compat=newest}
  14. usepgfplotslibrary{units}
  15. usetikzlibrary{spy, backgrounds}
  16. usepackage{pgfplotstable}
  17. usepackage{xcolor}
  18. usepackage{amsmath}
  19. %% To read variables from file
  20. usepackage{datatool}
  21. usepackage{filecontents}
  22.  
  23. newlengthfigurewidth
  24. newlengthfigureheight
  25. newlengthmarksize
  26.  
  27. begin{document}
  28. %% Width and height of the output figure, adapt as necessary
  29. setlength{figurewidth}{13cm}
  30. setlength{figureheight}{8cm}
  31. setlength{marksize}{2.4pt}
  32. setlength{linewidth}{1pt}
  33.  
  34. %% Define the file in here, as whole files cannot be uploaded to Tex.SE
  35. begin{filecontents}{LsqExponents.csv}
  36. 4.012,3.456,2.345
  37. end{filecontents}
  38. %% Now read these three values from the file
  39. DTLloaddb[noheader, keys={b_annu, b_rest, b_stra}]{LsqExponents}{LsqExponents.csv}
  40. %DTLdisplaydb{LsqExponents}
  41.  
  42. begin{tikzpicture}[font=large]
  43.  
  44. begin{axis}[%
  45. width=figurewidth,
  46. height=figureheight,
  47. scale only axis,
  48. xmin=0.05,
  49. xmax=0.5,
  50. xtick={0.1,0.2,0.3,0.4,0.5},
  51. xlabel={$text{T G S } gamma_mathrm{g} text{ (-)}$},
  52. %xmajorgrids,
  53. ymin=0,
  54. ymax=0.12,
  55. ylabel={$text{G R P } h_mathrm{g} text{ (-)}$},
  56. yticklabel style={/pgf/number format/fixed,
  57. /pgf/number format/precision=2,
  58. /pgf/number format/fixed zerofill},
  59. %ymajorgrids,
  60. name=plot1,
  61. legend pos=north west,
  62. legend style={anchor=north west,draw=black,fill=white,legend cell align=left, rounded corners=2pt, nodes={inner sep=4pt,text depth=0pt}}
  63. ]
  64. %% Fits and functions
  65. addplot [color=cyan, solid, domain=0:0.5] {x^4.567};
  66. addlegendentry{Original TD Fit};
  67.  
  68. addplot [color=magenta, dashed, domain=0:0.5] {x^3.456};
  69. addlegendentry{TD-like Fit for Rest};
  70.  
  71. addplot [color=black, dashed, domain=0:0.5] {x^2.345};
  72. addlegendentry{TD-like Fit for Stra};
  73.  
  74. end{axis}
  75.  
  76. end{tikzpicture}
  77.  
  78. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement