[R] 4 dimensional graphics
jiho
jo.irisson at gmail.com
Thu Jan 10 18:46:12 CET 2008
On 2008-January-10 , at 17:41 , Petr PIKAL wrote:
> Thank you
>
> Basically I have a rectangular space (like an aquarium) in which I
> made
> some analysis.
> I can make
>
> image(lat, long, value) for each height but what I dream about is to
> make
> something like scatterplot3d(lat, long, height) with points set
> according
> to a value.
>
> Up to now i can do
>
> scatterplot3d(sloupecn, radan, vrstvan, color=as.numeric(cut(value,
> c(0,
> 100, 400, 1000))))
>
> which will give you green and red points in upper right corner. I
> started
> to try to make cex.symbols scaled according to value too but up to
> now I
> did not manage to work correctly.
>
> in
>
> scatterplot3d(sloupecn, radan, vrstvan, cex.symbols = value/
> max(value)+2,
> color=as.numeric(cut(value, c(0, 100, 400, 1000))))
>
> the biggest points are at other places then I expected.
so you have measures at x,y,z points basically. and your measures
appear to be on z layers so you can probably make several x,y plots
with point size according to value, stacked on top of each other or
side by side. one liner ggplots:
A=read.table("petr.txt",header=T)
library("ggplot2")
# stacked
ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value, colour=factor(z)))
+ scale_size(to=c(0,10)) + scale_colour_hue(alpha=0.3)
# side by side
ggplot(A,aes(x=x,y=y)) + geom_point(aes(size=value)) +
scale_size(to=c(0,10)) +facet_grid(z~.)
if you want 3d to explore your data, rgl (in which you can rotate
plots etc) is probably the best choice
# 3D with rgl
library("rgl")
open3d()
spheres3d(A$x,A$y,A$z,A$value/1000)
# NB. scaling your value is necessary since the values are so big
compared to the coordinates
axes3d()
hope that helps.
petr.txt:
x y z value
1 4 1 73.8
1 4 9 54.9
1 4 17 72
1 1 1 96
1 1 9 52.1
1 1 17 53.3
4 4 1 58.4
4 4 9 93.5
4 4 17 140.2
4 1 1 90.3
4 1 9 36.5
4 1 17 55.1
7 4 1 169.1
7 4 9 718
7 4 17 813
7 1 1 73.4
7 1 9 46.5
7 1 17 205
JiHO
---
http://jo.irisson.free.fr/
More information about the R-help
mailing list