1

I have a graph like this:

enter image description here

However, when I plot it out on LaTex, it turns out like this: enter image description here

Here is the code:

\begin{figure}[H]
\centering
\psset{xunit=0.13cm,yunit=0.5cm,algebraic=true,dimen=middle,dotstyle=o,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(122.,-2.)(182.,11.)
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=5.,Dy=1]{->}(0,0)(122.,-2.)(182.,11.)
\psline(135.,0.)(135.,7.)
\psline(140.,0.)(140.,7.)
\psline(140.,7.)(135.,7.)
\psline(145.,0.)(145.,4.)
\psline(145.,4.)(140.,4.)
\psline(150.,0.)(150.,9.)
\psline(145.,4.)(145.,9.)
\psline(145.,9.)(150.,9.)
\psline(155.,0.)(155.,5.)
\psline(155.,5.)(150.,5.)
\psline(160.,0.)(160.,2.)
\psline(160.,2.)(155.,2.)
\psline(170.,0.)(170.,1.)
\psline(165.,0.)(165.,1.)
\psline(165.,1.)(170.,1.)
\end{pspicture*}
\end{figure}

How do I make the y-axis appear?

Thank you!

1

Maybe you are interested in a pgfplots solution which is quite short:

% arara: pdflatex

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

\begin{document}    
\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{axis}[ymin=0, xmin=122, xmax=182,axis x line=bottom,axis y line=left,font=\scriptsize] 
            \addplot[ybar interval] coordinates {%
                (135,7) (140,4) (145,9) (150,5) (155,2) (160,0) (165,1) (170,0)
                };
        \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}
1

use

\psaxes[labelFontSize=\scriptstyle,Dx=5,]{->}(130,0)(122,-2)(182,11.)

the first pair of coordinates defines the intersection of the axes.

2
  • That's what I thought too, but when I changed (0,0) to (130,0), it gave me the x-axis starting from 0, 5, 10 and so on. Would like it to start from 130, 135, 140 and so on.
    – Eugene
    Mar 30 '15 at 12:54
  • 1
    use Ox=130 for the start value
    – user2478
    Mar 30 '15 at 14:11

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.