Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{pgfplots}pgfplotsset{compat=1.10}
  3. usepackage{pgfplotstable}
  4.  
  5. begin{document}
  6. begin{figure}
  7. begin{footnotesize}
  8. pgfplotstableread[col sep=comma, header=true]{
  9. unit,min,max
  10. A,0,5.27
  11. B,0,1.07
  12. C,-0.55,0.54
  13. D,-0.58,0.48
  14. E,0,0.14
  15. F,-0.1,0.09
  16. G,-0.04,0.03
  17. }loadedtable
  18. {
  19. begin{tikzpicture}
  20. begin{axis}[
  21. name=popaxis,
  22. scale only axis,
  23. xbar,
  24. xmin=0,
  25. xmax=6,
  26. %xmajorgrids=true,
  27. %xbar=2pt,
  28. width=0.4*textwidth, height= 0.2*textheight,
  29. y dir = reverse,
  30. nodes near coords = {pgfmathprintnumberpgfplotspointmeta},
  31. every node near coord/.append style={/pgf/number format/fixed,
  32. font=footnotesize,
  33. color=black},
  34. xticklabel= {pgfmathprintnumbertick},
  35. y tick label style={text width=3cm,align=center},
  36. axis x line=left,
  37. axis y line=none,
  38. %
  39. enlarge x limits = {value=0.15,upper},
  40. axis line style={-},
  41. clip=false
  42. ]
  43. addplot[gray,fill=lightgray!50] table[y expr =coordindex, x expr={thisrow{max}}] loadedtable;
  44. pgfplotstablegetrowsof{loadedtable}
  45. pgfmathsetmacro{lastrow}{pgfplotsretval-1}
  46. end{axis}
  47.  
  48. begin{axis}[
  49. at={(popaxis.north west)},anchor=north east, xshift=0.325cm,
  50. scale only axis,
  51. xbar = 0,
  52. xmin = -3,
  53. xmax = 0,
  54. %xmajorgrids=true,
  55. width=0.2*textwidth,
  56. height= 0.2*textheight,
  57. %x dir=reverse,
  58. y dir=reverse,
  59. nodes near coords = {pgfmathprintnumberpgfplotspointmeta},
  60. every node near coord/.append style={/pgf/number format/fixed, rotate = 0, anchor = east, font=footnotesize,
  61. color=black},
  62. xticklabel= {pgfmathprintnumbertick},
  63. axis x line=left,
  64. axis y line*=left,
  65. %
  66. ytick = data,
  67. yticklabels from table = {loadedtable}{unit},
  68. ytick align=center,
  69. ytick pos=left,
  70. enlarge x limits = {value=0.15,upper},
  71. axis line style={-}
  72. ]
  73. addplot[gray,fill=lightgray!50] table[y expr =coordindex, x expr={thisrow{min}}] loadedtable;
  74. end{axis}
  75. draw (0,0) -- (0,4);
  76. end{tikzpicture}
  77. }
  78.  
  79. end{footnotesize}
  80. end{figure}
  81.  
  82. begin{center}
  83. begin{figure}
  84. pgfplotstableread[col sep=comma, header=true]{
  85. unit,min,max
  86. A,77,86
  87. B,77,82
  88. C,74,80
  89. D,75,79
  90. E,77,78
  91. F,76,78
  92. G,76,78
  93. }loadedtable
  94.  
  95. resizebox{10cm}{!}{%
  96. begin{tikzpicture}
  97. begin{axis}[
  98. name=popaxis,
  99. scale only axis,
  100. xbar,
  101. xmin=77,
  102. xmax=87,
  103. %xmajorgrids=true,
  104. %xbar=2pt,
  105. %xlabel={%},
  106. width=10cm, height=8cm,
  107. y dir = reverse,
  108. nodes near coords = {pgfmathprintnumberpgfplotspointmeta},
  109. every node near coord/.append style={/pgf/number format/fixed,
  110. font=small,
  111. color=black},
  112. xticklabel= {pgfmathprintnumbertick},
  113. y tick label style={text width=3cm,align=center},
  114. axis x line=left,
  115. axis y line=none,
  116. enlarge x limits = {value=0,upper},
  117. axis line style={-},
  118. clip=false
  119. ]
  120. addplot[gray,fill=lightgray!50] table[y expr =coordindex, x expr={thisrow{max}}] loadedtable;
  121. pgfplotstablegetrowsof{loadedtable}
  122. pgfmathsetmacro{lastrow}{pgfplotsretval-1}
  123.  
  124. end{axis}
  125. begin{axis}[
  126. at={(popaxis.north west)},anchor=north east, xshift=0cm,
  127. scale only axis,
  128. xbar,
  129. allow reversal of rel axis cs=true,
  130. y dir=reverse,
  131. % x dir=reverse,
  132. %axis y line*=right,
  133. xmin=67,
  134. xmax=77,
  135. %xmajorgrids=true,
  136. width=10cm,
  137. height=8cm,
  138. nodes near coords = {pgfmathprintnumberpgfplotspointmeta},
  139. every node near coord/.append style={/pgf/number format/fixed, rotate = 0, anchor = east, font=footnotesize,
  140. color=black},
  141. xticklabel= {pgfmathprintnumbertick},
  142. axis x line=left,
  143. axis y line*=right,
  144. ytick = data,
  145. yticklabels from table = {loadedtable}{unit},
  146. ytick align=center,
  147. ytick pos=left,
  148. enlarge x limits = {value=0,upper},
  149. axis line style={-}
  150. ]
  151. addplot[gray,fill=lightgray!50] table[y expr =coordindex, x expr={thisrow{min}}] loadedtable;
  152. end{axis}
  153. draw (0,0) -- (0,8);
  154. end{tikzpicture}
  155. }
  156. end{figure}
  157. end{center}
  158.  
  159. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement