[pstricks] table with bar chart bars?

maja zaloznik maja.zaloznik at gmail.com
Wed Apr 13 23:40:30 CEST 2011


Thank you Herbert and Carsten for quick and educational replies!
I used Herbert's because it was first ;)
My data is from R so I used

> tbl <- cbind(tbl, paste("\\Bar", new.lbl[, 3], ";", sep = ""))

to get the final column to read the bar command automatically and it worked
like a charm!
Beautiful 350 row longtable without having to enter all the bar lengths by
hand!

Thanks guys!!!

Maja.




On 13 April 2011 17:46, Carsten Vogel <texnicer at web.de> wrote:

>
>
>
> Funny, while I was fighting source code and feeling sick because of my
> Gefrickel, I always thought: How would a pro like Herbert do it?
>
>
> \documentclass{scrartcl}
> \usepackage[english]{babel}
> \usepackage[T1]{fontenc}
> \usepackage{lmodern}
> \usepackage{booktabs}
> \usepackage{pst-plot}
> \usepackage{calc}
> \usepackage{multido}
> \usepackage{capt-of}
> \usepackage[babel]{csquotes}
>
>
> \newlength{\MaxWidth}\setlength{\MaxWidth}{5cm}
> \newlength{\BarHeight}\setlength{\BarHeight}{1.2ex}
> \xdefinecolor{Bar1}{rgb}{0.8,0.8,1.0}
>
>
> \newpsstyle{Bar}{fillstyle=solid,fillcolor=Bar1,linewidth=.7pt,linecolor=black}
> \newcommand{\Bar}[1]{\psframe[style=Bar](#1,\BarHeight)}
>
>
> \newcommand{\Scale}{%
>        \multido{\Na=0+1}{6}{%
>                \psline(\Na,.2)(\Na,.3)%
>                \rput[t](\Na,.1){\footnotesize\sffamily\Na}%
>        }%
>        \psline(0,.2)(\MaxWidth,.2)
> }
>
>
> \begin{document}
> \noindent{\Large Something more straigthforward, vielleicht}\par\bigskip
> \captionof{table}[Example 1]{Custom \enquote{bar-chart}}
> \noindent\begin{center}\begin{tabular}{llp{\MaxWidth}}\toprule
> Column1                 & Column2       & Column3\\\midrule
> Content1                & Content2      & \Bar{4.2}\\\addlinespace
> Content3                & Content4      & \Bar{3.5}\\\addlinespace
> Content5                & Content6      & \Bar{1.5}\\\addlinespace
> Content7                & Content8      & \Bar{4.5}\\\addlinespace
> Content9                & Content10     & \Bar{2.75}\\\addlinespace
>                                        &
>     & \Scale\\\addlinespace
> \bottomrule\end{tabular}\end{center}
> \end{document}
>
> _______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
> archive: http://www.tug.org/pipermail/pstricks/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20110413/3a02c75a/attachment.html>


More information about the PSTricks mailing list