Wolfram Fischer
2003-Jan-15 12:13 UTC
[R] lattice: cloud: aspect ratio, labels, vertical lines
I am interested to know how to make for clouds: - aspect ratio = 1 - labels attached to points - vertical lines from the points to the x/y base plane I tried: t = c( 'A', 'B', 'C', 'D' ) x = c( 100, 0, 200, 100 ) y = c( 0, 100, 0, 100 ) z = c( 80, 0, 20, 40 ) q = data.frame( x, y, z ) rownames( q ) = t print(cloud( z ~ x * y, data = q, type = c( 'p', 'h' ) , scales = list( arrows=FALSE ) , aspect = c( max(y)/max(x), max(z)/max(x) ) )) My questions: - Is there an easier way to tell that aspect ratio should be 1 on all dimensions, especially without the precalculations of max(...)? - "type = 'h'" does not work as I expected. What to do? - How can I get the labels of t into the graphic? Thanks Wolfram
Deepayan Sarkar
2003-Jan-16 00:04 UTC
[R] lattice: cloud: aspect ratio, labels, vertical lines
On Wednesday 15 January 2003 05:15 am, Wolfram Fischer wrote:> I am interested to know how to make for clouds: > - aspect ratio = 1 > - labels attached to points > - vertical lines from the points to the x/y base plane > > I tried: > t = c( 'A', 'B', 'C', 'D' ) > x = c( 100, 0, 200, 100 ) > y = c( 0, 100, 0, 100 ) > z = c( 80, 0, 20, 40 ) > > q = data.frame( x, y, z ) > rownames( q ) = t > > print(cloud( z ~ x * y, data = q, type = c( 'p', 'h' ) > , scales = list( arrows=FALSE ) > , aspect = c( max(y)/max(x), max(z)/max(x) ) > )) > > > My questions: > - Is there an easier way to tell that aspect ratio should be 1 > on all dimensions, especially without the precalculations > of max(...)?You mean that the aspect ratio should be 1 on the data scale ? This is not currently possible, but I have plans to add this, among other things, in the next major release.> - "type = 'h'" does not work as I expected. What to do?This is partially implemented, but not the default yet (and not widely advertised). Try print(cloud( z ~ x * y, data = q, type = 'h' , panel.3d.cloud = panel.3dscatter.new, , scales = list( arrows=FALSE ) , aspect = c( max(y)/max(x), max(z)/max(x) ) )) type cannot be a vector, but that's not a major problem (see below).> - How can I get the labels of t into the graphic?Something like: panel.custom <- function(x, y, z, groups, subscripts, rot.mat = diag(4), za, zb, zback, zfront, distance, ...) { panel.3dscatter.new(x, y, z, type = 'h', rot.mat = rot.mat, za = za, zb = zb, zback = zback, zfront = zfront, distance = distance, ...) m <- ltransform3dto3d(rbind(x, y, z), rot.mat, za, zb, zback, zfront, distance) ltext(x = m[1,], y = m[2,], lab = groups[subscripts]) } print(cloud( z ~ x * y, data = q, groups = rownames(q), xlim = c(-10, 210), ylim = c(-5, 105), panel.3d.cloud = panel.custom, scales = list( arrows=FALSE ), aspect = c( max(y)/max(x), max(z)/max(x) ) )) The point being that the ltransform3dto3d() function makes the projection easily enough for normal users to use it inside a custom panel.3d.cloud function. Deepayan