[pstricks] \psbarchart

Michael Sharpe msharpe at ucsd.edu
Sun Mar 15 02:02:02 CET 2009


On Mar 14, 2009, at 5:05 PM, David Arnold wrote:

> All,
>
> Trying to do this:
>
> \documentclass[12pt]{article}
> \usepackage{pstricks}
> \usepackage{pst-bar}
> \usepackage{pstricks-add}
> \usepackage{pst-plot}
> \usepackage{pst-tree}
> \usepackage{filecontents}
>
> \begin{document}
>
> \begin{filecontents*}{ChangeInDow.csv}
> Sun, Mon, Tue, Wed, Thu, Fri, Sat
> 7000, 6900, 6899, 6800, 7000, 7100, 7200
> \end{filecontents*}
>
> \begin{figure}[h]
> \centering
> \psset{xunit=0.5in,yunit=0.0015in}
> \begin{pspicture}(0,6000)(8,8000)
> \psframe[fillstyle=solid,fillcolor=black!10,linestyle=solid](0,6000)
> (8,8000)
> \psaxes[yticksize=0 8,ticks=y,labels=y,Dx=1,Oy=6000,Dy=100](0,6000)
> (0,6000)(8,8000)
> \readpsbardata[header=true]{\data}{ChangeInDow.csv}
> \psbarchart[barstyle=blue]{\data}
> \end{pspicture}
> \caption{Profit and loss bar graph.\label{fig:ChangeInDow}}
> \end{figure}
>
> \end{document}
>
> But not working. Bars go off the bottom of the page. Where am I going
> wrong?

You have to scale the data using \psbarscale. It appears that pst-bar  
has no automatic way to handle bars that extend beyond the axes frame.  
Effectively, let y range from 0 to 2000 and subtract 600 from all data  
values.

Michael


\documentclass[12pt]{article}
\usepackage{pstricks}
\usepackage{pst-bar}
\usepackage{pstricks-add}
\usepackage{filecontents}

\begin{document}

\begin{filecontents*}{ChangeInDow.csv}
Sun, Mon, Tue, Wed, Thu, Fri, Sat
7000, 6900, 6899, 6800, 7000, 7100, 7200
\end{filecontents*}

\begin{figure}[h]
\centering
\psset{xunit=0.5in,yunit=0.0015in}
\begin{pspicture}(0,0)(8,2000)
\psframe[fillstyle=solid,fillcolor=black!10,linestyle=solid](0,0)
(8,2000)
\psaxes[yticksize=0 8,ticks=y,labels=y,Dx=1,Oy=6000,Dy=200](0,0)
(0,0)(8,2000)
\psbarscale(1){6000 sub}
\readpsbardata[header=true]{\data}{ChangeInDow.csv}
\psbarchart[barstyle=blue]{\data}
\end{pspicture}
\caption{Profit and loss bar graph.\label{fig:ChangeInDow}}
\end{figure}

\end{document}



More information about the PSTricks mailing list