Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. documentclass{minimal}
  2. usepackage{pgfplots}
  3. usepgfplotslibrary{dateplot}
  4. begin{filecontents}{data.dat}
  5. date value1
  6. 2010-01-01 2
  7. 2010-01-02 10
  8. 2010-01-03 8
  9. 2010-01-04 15
  10. end{filecontents}
  11. usepackage{pgfplotstable}
  12. begin{document}
  13. begin{tikzpicture}
  14.  
  15. begin{axis}[
  16. date coordinates in=x,
  17. xticklabel={day.month.year},
  18. xmin={2010-01-01},
  19. xmax={2010-01-05},x tick label style={yshift=-3pt,xshift=-4pt,rotate=-30,anchor=west}]
  20. addplot table [x=date,y=value1] {data.dat};
  21. addplot table [x=date, y={create col/linear regression={y=value1}}] {data.dat};
  22. end{axis}
  23.  
  24. end{tikzpicture}
  25. end{document}
  26.  
  27. documentclass{minimal}
  28. usepackage{pgfplots}
  29. usepgfplotslibrary{dateplot}
  30. begin{filecontents}{data.dat}
  31. date value1
  32. 2010-01-01 2
  33. 2010-01-02 10
  34. 2010-01-03 8
  35. 2010-01-04 15
  36. end{filecontents}
  37. usepackage{pgfplotstable}
  38.  
  39. % formats row ticknum of the input table using '#3'
  40. % #1: table name
  41. % #2: column name
  42. % #3: formatting instruction like day.month.year
  43. newcommanddatelabelsfromtable[3]{%
  44. begingroup
  45. countdefresult=count200 %
  46. pgfplotstablegetelem{ticknum}{#2}of{#1}%
  47. pgfcalendardatetojulian{pgfplotsretval}{result}%
  48. pgfcalendarjuliantodate{result}yearmonthday
  49. %
  50. #3%
  51. endgroup
  52. }
  53.  
  54. begin{document}
  55. begin{tikzpicture}
  56.  
  57. begin{axis}[
  58. x tick label style={yshift=-3pt,xshift=-4pt,rotate=-30,anchor=west},
  59. xticklabel={datelabelsfromtable{data.dat}{date}{day.month.year}},
  60. xtick=data,
  61. ]
  62. addplot table [x expr=coordindex,y=value1] {data.dat};
  63. addplot table [x expr=coordindex, y={create col/linear regression={y=value1}}] {data.dat};
  64. end{axis}
  65.  
  66. end{tikzpicture}
  67. end{document}
  68.  
  69. documentclass{minimal}
  70. usepackage{pgfplots}
  71. usepgfplotslibrary{dateplot}
  72. begin{filecontents}{data.dat}
  73. date value1
  74. 2010-01-01 2
  75. 2010-01-02 10
  76. 2010-01-03 8
  77. 2010-01-04 15
  78. end{filecontents}
  79. usepackage{pgfplotstable}
  80. begin{document}
  81. begin{tikzpicture}
  82.  
  83. begin{axis}[
  84. x tick label style={yshift=-3pt,xshift=-4pt,rotate=-30,anchor=west},
  85. xticklabels={01.01.2010, 02.01.2010, 03.01.2010, 04.01.2010},
  86. xtick=data,
  87. ]
  88. addplot table [x expr=coordindex,y=value1] {data.dat};
  89. addplot table [x expr=coordindex, y={create col/linear regression={y=value1}}] {data.dat};
  90. end{axis}
  91.  
  92. end{tikzpicture}
  93. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement