[R] Variant of cloud with "sticks" from points to surface

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Oct 19 13:31:09 CEST 2009

On Mon, Oct 19, 2009 at 5:26 AM, PerfectTiling <perfecttiling at yahoo.com> wrote:
> Hi,
> I'd like to
>  (1) plot a perspective view of a 3D scatterplot, with a fitted (curved)
> surface;
>  (2) have a "stick" from each point vertically to the surface.
> The latter helps one visualize where a point lies in 3D, relative to the
> surface.  Is there a variant of the cloud function (lattice package) which
> might do this?  As far as I can tell, the cloud function will (essentially)
> only plot the a stick from a point to z=0, rather than to the surface.
> Thanks in advance!

 If you use the persp function from base graphics instead of cloud
from lattice you can then use the trans3d function to convert from
your 3d coords to 2d viewport coords. Then you can add the sticks
using 'lines' or 'segments'.

 There's an example usage in help(persp) where a sine-curve is plotted
along the edge of a 3d plot.

 I don't know if an equivalent transformation function exists for
lattice graphics.


More information about the R-help mailing list