LaTeX forum ⇒ Graphics, Figures & TablesLabelling 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

Labelling error bars  Topic is solved

Postby mayankmi » Fri Jul 05, 2013 5:54 am

The error bars are shown in the figure: is it possible to label them..
for example 7.5 should come for 1st one...etc etc
Also the color of error bars needs to be changed to black.

  1. \documentclass[12pt]{article}
  2.  
  3. \usepackage{graphicx}
  4. \usepackage{tikz}
  5. \usepackage{pgfplots}
  6.  
  7.  
  8. \begin{document}
  9.  
  10. \begin{figure}[htbp]
  11. \centering
  12. \begin{tikzpicture}[scale=1],
  13. \centering
  14. \begin{axis}[
  15. height=8cm,
  16. width=14cm,
  17. ymax=45,
  18. ymin=20,
  19. xmin=0.5,
  20. xmax=4.5,
  21. ylabel=Elastic Modulus E (Gpa),
  22. axis y line*=left,
  23. axis x line*=bottom,
  24. xticklabels={Normal Prior-Literature,Normal Posterior-1st update,Normal Posterior-2nd update,Normal Posterior-Final},xtick={1,...,4},
  25. x tick label style={rotate=90,anchor=east}]
  26. \addplot+[only marks][error bars/.cd,y dir=both, y explicit]
  27. coordinates {
  28. (4,32.26) +- (0,4.8)
  29. (3,32.7) +- (0.0,5.89)
  30. (2,33.21) +- (0,7.25)
  31. (1,35) +- (0,7.5)
  32. };
  33. \addplot[color=black] coordinates {(1,35) (2,33.21) (3,32.7) (4,32.26)};
  34. \end{axis}
  35. \end{tikzpicture}%
  36. \caption{Plot showing update after each data step}
  37. \label{fig:bayesianupdatingstepswithoutt}
  38. \end{figure}
  39.  
  40. \end{document}

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3582
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Fri Jul 05, 2013 8:05 am

I would recommend to give the uncertainty in a little table. Plots are for visualisation and comparison of data-points. But you could do something like this. Thorsten is more experienced with tikz and pgfplots than me, he might have a better idea.

  1. \documentclass{article}
  2. \usepackage{pgfplots}
  3. \begin{document}
  4.  
  5. \begin{figure}
  6. \centering
  7. \begin{tikzpicture}[scale=1],
  8. \centering
  9. \begin{axis}[
  10. height=8cm,
  11. width=14cm,
  12. ymax=45,
  13. ymin=20,
  14. xmin=0.5,
  15. xmax=4.5,
  16. ylabel=Elastic Modulus E (Gpa),
  17. xticklabels={Normal
  18. Prior-Literature,Normal Posterior-1st
  19. update,Normal Posterior-2nd
  20. update,Normal
  21. Posterior-Final},xtick={1,...,4},
  22. x tick label
  23. style={rotate=90,anchor=east}]
  24. \addplot+[black,only marks][error bars/.cd,y dir=both, y explicit]
  25. coordinates {
  26. (4,32.26) +- (0,4.8)
  27. (3,32.7) +- (0.0,5.89)
  28. (2,33.21) +- (0,7.25)
  29. (1,35) +- (0,7.5)
  30. };
  31. \node at (axis cs:4,32.26) [pin={170:4.8},inner sep=0pt] {};
  32. \node at (axis description cs: 0.16,.5) {7.5};
  33. \end{axis}
  34. \end{tikzpicture}%
  35. \end{figure}
  36. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

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

Postby mayankmi » Fri Jul 05, 2013 10:14 pm

ya this is ok.. but is it possible to draw normal distribution on these error bars..it has to inverted of course... so like for 4 error bars four normal distribution . i dont know if its too much to ask from latex.. 8-)


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 4 guests