[pstricks] 3D histogram with pst-solides3d

mathias legrand legrand.mathias at gmail.com
Mon Aug 16 21:26:01 CEST 2010


  Hi all,

I've been thinking of this for a long time: automatically draw3D histrograms
with pstricks. I talked to Manuel about this several times and even in 
this forum
but I do not know where to start.

Chapter 12 of the pst-solides3d guide about "Possible extensions" 
details how to draw
your own objects. That may be an interesting starting point but I am not 
sure.
What would be nice is something similar to the savedata and dataplot 
commands for 2D diagrams.
Here, we would provide a list of (x, y) positions and z heights, pick 
two colors (here
green and red) and then the command to be invented would draw what's 
below (for instance).

The fact that bars stand behind others is not automatically accounted 
for, unfortunately, but
it gives the idea. The c height as well as the percentage of colour mix 
would be automatically
calculated based on the z value.

Fro instance:
\savedata{\my3Dhist}[{
{1,1,0.1}, {1,2,3}, {2,1,2},.....]}
and then:
\begin{pspicture}
....
\3Dhistplot[option]{\my3Dhist}
.....
\end{pspicture}
Would pro of pstricks and pst-solides3d be able to implement this?

Thank  you,

M.


Here is what i can get by hand.... ;(


\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pst-solides3d}
\pagestyle{empty}
\begin{document}
\begin{pspicture}[showgrid=false](0,-3)(8,8)%
\psset{lightsrc=10 -20 50,viewpoint=30 -50 40 rtp2xyz,Decran=30,ngrid=5 
5,solidmemory,unit=1}%
% 3D frame
\psSolid[object=grille,base=0 6 0 
6,fillcolor=gray!10,linecolor=gray!20,linewidth=0.5\pslinewidth](0,0,0)%
\psSolid[object=grille,base=0 6 0 
6,fillcolor=gray!30,linecolor=gray!20,RotX=90,linewidth=0.5\pslinewidth](0,6,0)%
\psSolid[object=grille,base=0 6 0 
6,fillcolor=gray!50,linecolor=gray!20,RotY=90,linewidth=0.5\pslinewidth](0,0,6)%
% 3D histogram
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=6,fillcolor=green!60!red](0.5,0.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=4.5,fillcolor=green!45!red](2.5,2.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=3.3,fillcolor=green!33!red](1.5,2.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=2,fillcolor=green!20!red](2.5,0.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=3,fillcolor=green!30!red](1.5,0.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=5,fillcolor=green!50!red](2.5,0.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=2.5,fillcolor=green!25!red](2.5,2.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=1.1,fillcolor=green!11!red](3.5,3.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=1,fillcolor=green!10!red](3.5,1.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=0.5,fillcolor=green!5!red](4.5,4.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=2.5,fillcolor=green!25!red](4.5,3.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=4,fillcolor=green!40!red](4.5,2.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=1.1,fillcolor=green!11!red](4.5,1.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=1,fillcolor=green!10!red](4.5,0.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=0.1,fillcolor=green!1!red](5.5,5.5,c 
2 div)%
\psSolid[object=parallelepiped,a=0.75,b=0.75,c=6,fillcolor=green!60!red](5.5,4.5,c 
2 div)%
\end{pspicture}
\end{document}


More information about the PSTricks mailing list