LaTeX forum ⇒ Graphics, Figures & TablesNormal Distribution on Error Bars Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm
Location: portugal

Normal Distribution on Error Bars  Topic is solved

Postby mayankmi » Fri Jul 12, 2013 2:04 am

This is a bit tough. I tried to draw normal distribution on every error bar. Since in this case the normal distribution has to be inverted. For example 1st normal distribution will be having mean 35 and standard deviation of 7.5. I tried to search so many things but every time they draw y as function of x. I am trying this for two days but could not find it.

  1. \documentclass{article}
  2. \usepackage{pgfplots}
  3.  
  4. \begin{document}
  5. \begin{figure}[!htb]
  6. \centering
  7. \begin{tikzpicture}[scale=1],
  8. \begin{axis}[
  9. height=8cm,
  10. width=14cm,
  11. xmin=0,
  12. xmax=4.5,
  13. ymax=45,
  14. ymin=20,
  15. ylabel={Elastic Modulus E (Gpa)},
  16. axis x line*=bottom,
  17. axis y line*=left,
  18. xticklabels={1,2,3,4},xtick={1,...,4},
  19. x tick label style={anchor=east}
  20. ]
  21. \addplot+[black,only marks][error bars/.cd,y dir=both, y explicit] coordinates {
  22. (4,32.32) +- (0,7.52)
  23. (3,32.73) +- (0.0,8.0)
  24. (2,33.24) +- (0,8.38)
  25. (1,35) +- (0,7.5)
  26. };
  27. \node at (axis cs:4,32.32) [pin={120:(32.32,7.52)},inner sep=0pt] {};
  28. \node at (axis cs:3,32.73) [pin={130:(32.73,8.0)},inner sep=0pt] {};
  29. \node at (axis cs:2,33.24) [pin={130:(33.24,8.38)},inner sep=0pt] {};
  30. \node at (axis cs:1,35) [pin={130:(35,7.5)},inner sep=0pt] {};
  31. \addplot[color=black] coordinates {(1,35) (2,33.24) (3,32.73) (4,32.32)};
  32. \end{axis}
  33. \end{tikzpicture}%
  34. \caption{Plot showing update for elastic modulus after each data step with trust factor}
  35. \label{fig:bayesianupdatingstepsincludingt}
  36. \end{figure}
  37. \end{document}

Tags:

mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm
Location: portugal

Postby mayankmi » Fri Jul 12, 2013 5:30 am

I had used this, but it is a super long code and it also compiles very slowly. :cry:

  1. \documentclass{article}
  2. \usepackage{pgfplots,pgfplotstable}
  3.  
  4. \usepackage{filecontents}
  5. \begin{filecontents}{dataA.txt}
  6. 1.00226226913365
  7. 1.00312239104362
  8. 1.00398127101215
  9. 1.00483763991946
  10. 1.00569020162844
  11. 1.00653763603497
  12. 1.00737860228023
  13. 1.00821174211507
  14. 1.00903568340546
  15. 1.00984904376729
  16. 1.01065043431763
  17. 1.01143846352885
  18. 1.01221174117105
  19. 1.01296888232776
  20. 1.01370851146886
  21. 1.01442926656443
  22. 1.01512980322243
  23. 1.01580879883290
  24. 1.01646495670100
  25. 1.01709701015087
  26. 1.01770372658228
  27. 1.01828391146207
  28. 1.01883641223215
  29. 1.01936012211647
  30. 1.01985398380919
  31. 1.02031699302696
  32. 1.02074820190871
  33. 1.02114672224672
  34. 1.02151172853358
  35. 1.02184246081058
  36. 1.02213822730355
  37. 1.02239840683350
  38. 1.02262245099031
  39. 1.02280988605871
  40. 1.02296031468724
  41. 1.02307341729179
  42. 1.02314895318695
  43. 1.02318676143945
  44. 1.02318676143945
  45. 1.02314895318695
  46. 1.02307341729179
  47. 1.02296031468724
  48. 1.02280988605871
  49. 1.02262245099031
  50. 1.02239840683350
  51. 1.02213822730355
  52. 1.02184246081058
  53. 1.02151172853358
  54. 1.02114672224672
  55. 1.02074820190871
  56. 1.02031699302696
  57. 1.01985398380919
  58. 1.01936012211647
  59. 1.01883641223215
  60. 1.01828391146207
  61. 1.01770372658228
  62. 1.01709701015087
  63. 1.01646495670100
  64. 1.01580879883290
  65. 1.01512980322243
  66. 1.01442926656443
  67. 1.01370851146886
  68. 1.01296888232776
  69. 1.01221174117105
  70. 1.01143846352885
  71. 1.01065043431763
  72. 1.00984904376729
  73. 1.00903568340546
  74. 1.00821174211507
  75. 1.00737860228023
  76. 1.00653763603497
  77. 1.00569020162844
  78. 1.00483763991946
  79. 1.00398127101215
  80. 1.00312239104362
  81. 1.00226226913365
  82. \end{filecontents}
  83.  
  84. \begin{filecontents}{dataB.txt}
  85. 27.5000000000000
  86. 27.7000000000000
  87. 27.9000000000000
  88. 28.1000000000000
  89. 28.3000000000000
  90. 28.5000000000000
  91. 28.7000000000000
  92. 28.9000000000000
  93. 29.1000000000000
  94. 29.3000000000000
  95. 29.5000000000000
  96. 29.7000000000000
  97. 29.9000000000000
  98. 30.1000000000000
  99. 30.3000000000000
  100. 30.5000000000000
  101. 30.7000000000000
  102. 30.9000000000000
  103. 31.1000000000000
  104. 31.3000000000000
  105. 31.5000000000000
  106. 31.7000000000000
  107. 31.9000000000000
  108. 32.1000000000000
  109. 32.3000000000000
  110. 32.5000000000000
  111. 32.7000000000000
  112. 32.9000000000000
  113. 33.1000000000000
  114. 33.3000000000000
  115. 33.5000000000000
  116. 33.7000000000000
  117. 33.9000000000000
  118. 34.1000000000000
  119. 34.3000000000000
  120. 34.5000000000000
  121. 34.7000000000000
  122. 34.9000000000000
  123. 35.1000000000000
  124. 35.3000000000000
  125. 35.5000000000000
  126. 35.7000000000000
  127. 35.9000000000000
  128. 36.1000000000000
  129. 36.3000000000000
  130. 36.5000000000000
  131. 36.7000000000000
  132. 36.9000000000000
  133. 37.1000000000000
  134. 37.3000000000000
  135. 37.5000000000000
  136. 37.7000000000000
  137. 37.9000000000000
  138. 38.1000000000000
  139. 38.3000000000000
  140. 38.5000000000000
  141. 38.7000000000000
  142. 38.9000000000000
  143. 39.1000000000000
  144. 39.3000000000000
  145. 39.5000000000000
  146. 39.7000000000000
  147. 39.9000000000000
  148. 40.1000000000000
  149. 40.3000000000000
  150. 40.5000000000000
  151. 40.7000000000000
  152. 40.9000000000000
  153. 41.1000000000000
  154. 41.3000000000000
  155. 41.5000000000000
  156. 41.7000000000000
  157. 41.9000000000000
  158. 42.1000000000000
  159. 42.3000000000000
  160. 42.5000000000000
  161. \end{filecontents}
  162.  
  163. \pgfplotstableset{
  164. create on use/Y/.style={create col/copy column from table={dataB.txt}{0}}
  165. }
  166.  
  167. \begin{filecontents}{dataC.txt}
  168. 1.04332933837174
  169. 1.04562759799475
  170. 1.04790362827434
  171. 1.05013371989158
  172. 1.05229338408093
  173. 1.05435778459123
  174. 1.05630220238241
  175. 1.05810252127097
  176. 1.05973572142331
  177. 1.06118036672514
  178. 1.06241707168585
  179. 1.06342893370566
  180. 1.06420191725237
  181. 1.06472517775032
  182. 1.06499131473688
  183. 1.06499654602633
  184. 1.06474079715211
  185. 1.06422770313069
  186. 1.06346452248881
  187. 1.06246196639620
  188. 1.06123394852609
  189. 1.05979726380824
  190. 1.05817120643961
  191. 1.05637713928919
  192. 1.05443802811000
  193. 1.05237795471225
  194. 1.05022162344257
  195. 1.04799387496574
  196. 1.04571922049369
  197. 1.04342140830877
  198. \end{filecontents}
  199.  
  200. \begin{filecontents}{dataD.txt}
  201. 25.9500000000000
  202. 26.4500000000000
  203. 26.9500000000000
  204. 27.4500000000000
  205. 27.9500000000000
  206. 28.4500000000000
  207. 28.9500000000000
  208. 29.4500000000000
  209. 29.9500000000000
  210. 30.4500000000000
  211. 30.9500000000000
  212. 31.4500000000000
  213. 31.9500000000000
  214. 32.4500000000000
  215. 32.9500000000000
  216. 33.4500000000000
  217. 33.9500000000000
  218. 34.4500000000000
  219. 34.9500000000000
  220. 35.4500000000000
  221. 35.9500000000000
  222. 36.4500000000000
  223. 36.9500000000000
  224. 37.4500000000000
  225. 37.9500000000000
  226. 38.4500000000000
  227. 38.9500000000000
  228. 39.4500000000000
  229. 39.9500000000000
  230. 40.4500000000000
  231. \end{filecontents}
  232.  
  233. \pgfplotstableset{
  234. create on use/Y1/.style={create col/copy column from table={dataD.txt}{0}}
  235. }
  236. \begin{filecontents}{dataE.txt}
  237. 1.09101228343449
  238. 1.09447941324231
  239. 1.09789444153755
  240. 1.10120261508366
  241. 1.10434757064717
  242. 1.10727288941488
  243. 1.10992375455518
  244. 1.11224864521472
  245. 1.11420099454742
  246. 1.11574073760134
  247. 1.11683567735022
  248. 1.11746260387057
  249. 1.11760811234224
  250. 1.11726907960912
  251. 1.11645277563712
  252. 1.11517660431372
  253. 1.11346748649650
  254. 1.11136091585605
  255. 1.10889973375728
  256. 1.10613268221644
  257. 1.10311280311766
  258. 1.09989575690222
  259. 1.09653813469377
  260. 1.09309583442862
  261. \end{filecontents}
  262.  
  263. \begin{filecontents}{dataF.txt}
  264. 26.8000000000000
  265. 27.3000000000000
  266. 27.8000000000000
  267. 28.3000000000000
  268. 28.8000000000000
  269. 29.3000000000000
  270. 29.8000000000000
  271. 30.3000000000000
  272. 30.8000000000000
  273. 31.3000000000000
  274. 31.8000000000000
  275. 32.3000000000000
  276. 32.8000000000000
  277. 33.3000000000000
  278. 33.8000000000000
  279. 34.3000000000000
  280. 34.8000000000000
  281. 35.3000000000000
  282. 35.8000000000000
  283. 36.3000000000000
  284. 36.8000000000000
  285. 37.3000000000000
  286. 37.8000000000000
  287. 38.3000000000000
  288. \end{filecontents}
  289.  
  290. \pgfplotstableset{
  291. create on use/Y2/.style={create col/copy column from table={dataF.txt}{0}}
  292. }
  293.  
  294. \begin{filecontents}{dataG.txt}
  295. 1.15541817620221
  296. 1.16065061163684
  297. 1.16576316055689
  298. 1.17062939066174
  299. 1.17512033658057
  300. 1.17911006861182
  301. 1.18248150393679
  302. 1.18513209029711
  303. 1.18697897894796
  304. 1.18796332345033
  305. 1.18805339327479
  306. 1.18724627241532
  307. 1.18556801616595
  308. 1.18307225430180
  309. 1.17983734512559
  310. 1.17596229105113
  311. 1.17156171262816
  312. 1.16676023650359
  313. 1.16168667923444
  314. 1.15646840212709
  315. \end{filecontents}
  316.  
  317. \begin{filecontents}{dataH.txt}
  318. 27.5000000000000
  319. 28
  320. 28.5000000000000
  321. 29
  322. 29.5000000000000
  323. 30
  324. 30.5000000000000
  325. 31
  326. 31.5000000000000
  327. 32
  328. 32.5000000000000
  329. 33
  330. 33.5000000000000
  331. 34
  332. 34.5000000000000
  333. 35
  334. 35.5000000000000
  335. 36
  336. 36.5000000000000
  337. 37
  338. \end{filecontents}
  339.  
  340. \pgfplotstableset{
  341. create on use/Y3/.style={create col/copy column from table={dataH.txt}{0}}
  342. }
  343.  
  344. \begin{document}
  345. \begin{figure}[!htb]
  346. \centering
  347. \begin{tikzpicture}[scale=1],
  348. \begin{axis}[
  349. height=10cm,
  350. width=15cm,
  351. ymax=43,
  352. ymin=25,
  353. xmin=.97,
  354. xmax=1.2,
  355. ylabel=Elastic Modulus E (Gpa),
  356. xticklabels={1,2,3,4},xtick={1,1.05,1.1,1.15},
  357. x tick label
  358. style={anchor=east}
  359. ]
  360. \addplot+[black,only marks][error bars/.cd,y dir=both, y explicit] coordinates {
  361. (1.15,32.26) +- (0,4.8)
  362. (1.085,32.7) +- (0.0,5.89)
  363. (1.03,33.21) +- (0,7.25)
  364. (.99,35) +- (0,7.5)
  365. };
  366. \node at (axis cs:1.15,32.26) [pin={90:(32.26,4.8)},inner sep=0pt] {};
  367. \node at (axis cs:1.085,32.7) [pin={90:(32.7,5.89)},inner sep=0pt] {};
  368. \node at (axis cs:1.03,33.21) [pin={90:(33.21,7.25)},inner sep=0pt] {};
  369. \node at (axis cs:.99,35) [pin={90:(35,7.5)},inner sep=0pt] {};
  370. \addplot table [y=Y] {dataA.txt};
  371. \addplot table [y=Y1] {dataC.txt};
  372. \addplot table [y=Y2] {dataE.txt};
  373. \addplot table [y=Y3] {dataG.txt};
  374. \end{axis}
  375. \end{tikzpicture}
  376. \caption{Elastic modulus updating after different steps without trust factor}
  377. \label{finalfigureE}
  378. \end{figure}
  379. \end{document}


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 9 guests