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

6
  • 2
    did you search this site for bar plots?
    – percusse
    Dec 9 '14 at 12:04
  • yes, but I did not find the answer !
    – A.khalaf
    Dec 9 '14 at 12:11
  • 2
    You can combine tex.stackexchange.com/questions/11368/… and any barplot question with data is given as a table
    – percusse
    Dec 9 '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
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}
1
  • is it same if I used \documentclass[12pt,aps,nofootinbib,pra,amsmath,amssymb,floatfix]{revtex4-1} ?
    – A.khalaf
    Dec 13 '14 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.