[pstricks] table with bar chart bars?

Carsten Vogel texnicer at web.de
Wed Apr 13 18:46:45 CEST 2011




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}


More information about the PSTricks mailing list