# [R] three dimensions barchart

David Winsemius dwinsemius at comcast.net
Tue Aug 18 19:44:58 CEST 2009

```On Aug 18, 2009, at 7:18 AM, Yichih Hsieh wrote:

> Dear R community,
>
> I have one problem with figures.
>
> I draw the Relative Distribution graph,
> it looks like barchart(X,Y plot),
> but I have ten(year) Relative Distribution grapgs,
> have any command am can combine ten barcharts(X,Y plot) to become a
> three
> dimensions barchart(X,Y,Z plot)?
>

It has been my experience that the R-graphics experts generally
deprecate 3-D bar graphs, but there are some worked examples in the
supporting webpages for Sarkar's "Lattice" book:

Fig 6.4 (image followed by code)
http://dsarkar.fhcrc.org/lattice/book/images/Figure_06_04_stdBW.png

cloud(density ~ long + lat, state.info,
subset = !(name %in% c("Alaska", "Hawaii")), type = "h",
lwd = 2, zlim = c(0,
max(state.info\$density)), scales =
list(arrows = FALSE))
library("maps") state.map <- map("state", plot=FALSE, fill = FALSE)
panel.3dmap <- function(..., rot.mat, distance, xlim, ylim, zlim,
xlim.scaled,
ylim.scaled, zlim.scaled) {
scaled.val <- function(x, original, scaled) { scaled +
(x - original) * diff(scaled) /
diff(original) }

m <- ltransform3dto3d(rbind(scaled.val(state.map\$x, xlim,
xlim.scaled),
scaled.val(state.map\$y, ylim, ylim.scaled),
zlim.scaled),
rot.mat, distance) panel.lines(m[1,], m[2,], col =
"grey76") }

Fig 6.15 (image )
http://dsarkar.fhcrc.org/lattice/book/images/Figure_06_15_stdBW.png

code at:

http://lmdvr.r-forge.r-project.org/figures/figures.html#%20Figure%206.15

> All help highly appreciated
>
>
> Best,
> Yichih
>
>
> One Relative Distribution graph:
>
> bar=TRUE,yolabs=seq(-1,3,by=0.5),
> ylim=c(0,7),cex=0.8,ylab="Relative Density",xlab="Proportion of the
> Original
> Cohort")
> title(main="Fig2(b):2007",cex=0.6)
>
>
>
> --
> Yichih Hsieh
>
> e-mail : yichih.hsieh at gmail.com
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help