1

How I can Plot this curve in Latex {revtex4-1}?

\begin{center}
\begin{tikzpicture}
\begin{axis}[bar width=18pt,
 xtick=data,ymin=0,ymax=45,x tick label style=
{rotate=90,anchor=east}]
\addplot[ybar] coordinates{ (126.5  ,2 ) (134.5 ,4 ) (142.5 ,13) (150.5 ,20) (158.5 ,35) (166.5 ,33) (174.5 ,25) (182.5 ,17) (190.5 ,5 ) (198.5 ,3 )  };
\addplot +[smooth,black,mark = *,mark options={solid,black}]coordinates{ (126.5,    1.3 ) (134.5,   4.3 ) (142.5,   11.2) (150.5,   22.6) (158.5,   31.2) (166.5,   33.5) (174.5,   26.9) (182.5,   16.2) (190.5,   7.2 ) (198.5,   2.4 )};

enter image description here

darthbith
  • 7,384
A.khalaf
  • 351
  • 2
    did you search this site for bar plots? – percusse Dec 09 '14 at 12:04
  • yes, but I did not find the answer ! – A.khalaf Dec 09 '14 at 12:11
  • 2
    You can combine http://tex.stackexchange.com/questions/11368/bell-curve-gaussian-function-normal-distribution-in-tikz-pgf and any barplot question with data is given as a table – percusse Dec 09 '14 at 12:25
  • I did this code and there is no error but there is no result !! the code is `\begin{center} \begin{tikzpicture} \begin{axis}[bar width=18pt, xtick=data,ymin=0,ymax=45,x tick label style= {rotate=90,anchor=east}]

    \addplot[ybar] coordinates{ (126.5 ,2 ) (134.5 ,4 ) (142.5 ,13) (150.5 ,20) (158.5 ,35) (166.5 ,33) (174.5 ,25) (182.5 ,17) (190.5 ,5 ) (198.5 ,3 )

    };

    \addplot +[smooth,black,mark = *,mark options={solid,black}]coordinates{ (126.5, 1.3 ) (134.5, 4.3 ) (142.5, 11.2) (150.5, 22.6) (158.5, 31.2) (166.5, 33.5) (174.5, 26.9) (182.5, 16.2) (190.5, 7.2 ) (198.5, 2.4 )};`

    – A.khalaf Dec 10 '14 at 16:09
  • 1
    Can you please complete your code with \documentclass{...}, \begin{document}, whatever else you have in your axis, and \end{document}? – darthbith Dec 13 '14 at 14:23
  • \documentclass[12pt,aps,nofootinbib,pra,amsmath,amssymb,floatfix]{revtex4-1} and this is the packages that I useing \usepackage[paperwidth=210mm,paperheight=297mm,centering,hmargin={1.5cm,1.5cm},vmargin={3cm,3cm}]{geometry} \usepackage{graphicx} \usepackage{pgfplotstable} \usepackage{booktabs} \usepackage{pgfplots} \usepackage{placeins} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{textcomp} \usepackage{siunitx} \usepackage{mhchem} \usepackage{amsmath} \usepackage{multirow} – A.khalaf Dec 13 '14 at 22:41

1 Answers1

3

To get the desired format you can apply:

  • draw=red, pattern=north west lines, pattern color=red to provide the pattern for the fill of the bars
  • marks=none to eliminate the dots
  • /pgf/number format/fixed and /pgf/number format/precision=0 to control the display of the x ticks labels, and
  • ylabel={Count} and xlabel={Time}` to label the axis

enter image description here

Code:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{patterns}

\begin{document} \noindent \begin{tikzpicture} \begin{axis}[bar width=18pt, xtick=data,ymin=0,ymax=45, x tick label style={ rotate=90, anchor=east, /pgf/number format/fixed, /pgf/number format/precision=0, }, ylabel={Count}, xlabel={Time}, ] \addplot[ybar, draw=red, thick, pattern=north west lines, pattern color=red] coordinates{ (126.5 ,2 ) (134.5 ,4 ) (142.5 ,13) (150.5 ,20) (158.5 ,35) (166.5 ,33) (174.5 ,25) (182.5 ,17) (190.5 ,5 ) (198.5 ,3 ) }; \addplot +[smooth,black,mark=none, thick] coordinates{ (126.5, 1.3 ) (134.5, 4.3 ) (142.5, 11.2) (150.5, 22.6) (158.5, 31.2) (166.5, 33.5) (174.5, 26.9) (182.5, 16.2) (190.5, 7.2 ) (198.5, 2.4 )}; \end{axis} \end{tikzpicture}

\end{document}

Peter Grill
  • 223,288
  • is it same if I used \documentclass[12pt,aps,nofootinbib,pra,amsmath,amssymb,floatfix]{revtex4-1} ? – A.khalaf Dec 13 '14 at 22:39