# add points to lattice cloud plot (3D scatter)

10 messages
Open this post in threaded view
|

## add points to lattice cloud plot (3D scatter)

 Dear all, is it possible to add points to a lattice cloud plot (3D scatter)? I can plot the main data, but what if I wanted to add another point. In R there is the high level plotting function plot(), then the low level points() or lines() etc. What is the equivalent for lattice? Thank you >>> df = data.frame(Name = c("A", "B", "C", "D", "E"),               x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754),               y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652),               z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754),               stringsAsFactors = FALSE) cloud(z_axis ~ x_axis * y_axis, data = df,       xlab = "X", ylab = "Y", zlab = "Z",       pch = 16, col = "red", type = "b", cex = 1.5,       ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis,             labels=df\$Names, pos=1, offset=1, cex=0.8) ) df2 = data.frame(Name = "F",                 x_axis = 0.891,                 y_axis = 2.302                 z_axis = -1.83,                 stringsAsFactors = FALSE) -- Best regards, Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 Not sure whether this helps but try library(lattice) ?llines Note that is indeed a double ll at the start Michael On 28/02/2019 10:39, Luigi Marongiu wrote: > Dear all, > is it possible to add points to a lattice cloud plot (3D scatter)? I > can plot the main data, but what if I wanted to add another point. In > R there is the high level plotting function plot(), then the low level > points() or lines() etc. What is the equivalent for lattice? > > Thank you > > >>>> > > df = data.frame(Name = c("A", "B", "C", "D", "E"), >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), >                stringsAsFactors = FALSE) > > cloud(z_axis ~ x_axis * y_axis, data = df, >        xlab = "X", ylab = "Y", zlab = "Z", >        pch = 16, col = "red", type = "b", cex = 1.5, >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, >              labels=df\$Names, pos=1, offset=1, cex=0.8) > ) > > df2 = data.frame(Name = "F", >                  x_axis = 0.891, >                  y_axis = 2.302 >                  z_axis = -1.83, >                  stringsAsFactors = FALSE) > -- Michael http://www.dewey.myzen.co.uk/home.html______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 Thank uyou, but ?llines gives a method for 2 d plot: llines(x, y = NULL, ... when I try to plot 3 variables I get NULL as a result On Thu, Feb 28, 2019 at 12:52 PM Michael Dewey <[hidden email]> wrote: > > Not sure whether this helps but try > > library(lattice) > ?llines > > Note that is indeed a double ll at the start > > Michael > > On 28/02/2019 10:39, Luigi Marongiu wrote: > > Dear all, > > is it possible to add points to a lattice cloud plot (3D scatter)? I > > can plot the main data, but what if I wanted to add another point. In > > R there is the high level plotting function plot(), then the low level > > points() or lines() etc. What is the equivalent for lattice? > > > > Thank you > > > > > >>>> > > > > df = data.frame(Name = c("A", "B", "C", "D", "E"), > >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), > >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), > >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), > >                stringsAsFactors = FALSE) > > > > cloud(z_axis ~ x_axis * y_axis, data = df, > >        xlab = "X", ylab = "Y", zlab = "Z", > >        pch = 16, col = "red", type = "b", cex = 1.5, > >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, > >              labels=df\$Names, pos=1, offset=1, cex=0.8) > > ) > > > > df2 = data.frame(Name = "F", > >                  x_axis = 0.891, > >                  y_axis = 2.302 > >                  z_axis = -1.83, > >                  stringsAsFactors = FALSE) > > > > -- > Michael > http://www.dewey.myzen.co.uk/home.html-- Best regards, Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 In reply to this post by Luigi On 28/02/2019 5:39 a.m., Luigi Marongiu wrote: > Dear all, > is it possible to add points to a lattice cloud plot (3D scatter)? I > can plot the main data, but what if I wanted to add another point. In > R there is the high level plotting function plot(), then the low level > points() or lines() etc. What is the equivalent for lattice? I don't know for sure, but I don't think you can do that in lattice. The scatterplot3d::scatterplot3d function returns enough information to do this, but I don't think lattice::cloud does.  But even scatterplot3d::scatterplot3d won't necessarily get it right if points hide others that are behind them.  It uses the "painter's algorithm", and that needs everything to be drawn in just the right order, which you probably won't get if you draw things in several calls. You can draw things in arbitrary order using rgl::plot3d or related functions, but you'll need to do more work yourself to get an array of plots like lattice gives. Duncan Murdoch > > Thank you > > >>>> > > df = data.frame(Name = c("A", "B", "C", "D", "E"), >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), >                stringsAsFactors = FALSE) > > cloud(z_axis ~ x_axis * y_axis, data = df, >        xlab = "X", ylab = "Y", zlab = "Z", >        pch = 16, col = "red", type = "b", cex = 1.5, >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, >              labels=df\$Names, pos=1, offset=1, cex=0.8) > ) > > df2 = data.frame(Name = "F", >                  x_axis = 0.891, >                  y_axis = 2.302 >                  z_axis = -1.83, >                  stringsAsFactors = FALSE) > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 I see. I have been thinking of superimposing two plots with par(new=TRUE), but how could I remove all the graphic parameters (axes, background etc) keeping only the actual points in lattice? (if possible). Tx On Thu, Feb 28, 2019 at 3:53 PM Duncan Murdoch <[hidden email]> wrote: > > On 28/02/2019 5:39 a.m., Luigi Marongiu wrote: > > Dear all, > > is it possible to add points to a lattice cloud plot (3D scatter)? I > > can plot the main data, but what if I wanted to add another point. In > > R there is the high level plotting function plot(), then the low level > > points() or lines() etc. What is the equivalent for lattice? > > I don't know for sure, but I don't think you can do that in lattice. > The scatterplot3d::scatterplot3d function returns enough information to > do this, but I don't think lattice::cloud does.  But even > scatterplot3d::scatterplot3d won't necessarily get it right if points > hide others that are behind them.  It uses the "painter's algorithm", > and that needs everything to be drawn in just the right order, which you > probably won't get if you draw things in several calls. > > You can draw things in arbitrary order using rgl::plot3d or related > functions, but you'll need to do more work yourself to get an array of > plots like lattice gives. > > Duncan Murdoch > > > > > > Thank you > > > > > >>>> > > > > df = data.frame(Name = c("A", "B", "C", "D", "E"), > >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), > >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), > >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), > >                stringsAsFactors = FALSE) > > > > cloud(z_axis ~ x_axis * y_axis, data = df, > >        xlab = "X", ylab = "Y", zlab = "Z", > >        pch = 16, col = "red", type = "b", cex = 1.5, > >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, > >              labels=df\$Names, pos=1, offset=1, cex=0.8) > > ) > > > > df2 = data.frame(Name = "F", > >                  x_axis = 0.891, > >                  y_axis = 2.302 > >                  z_axis = -1.83, > >                  stringsAsFactors = FALSE) > > > -- Best regards, Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 You are missing the point... lattice assembles the entire data set at once so it can adjust and synchronize all of the scales and then it generates an object that can be printed to a device. This approach is entirely incompatible with the base graphics approach of keeping global variables around that help successive functions cooperate to cumulatively build up an image. You need to get all your points into the lattice call initially. which may involve changing how you structure the data before you create the plot. Read the vignette and some tutorials. On February 28, 2019 7:38:52 AM PST, Luigi Marongiu <[hidden email]> wrote: >I see. I have been thinking of superimposing two plots with >par(new=TRUE), but how could I remove all the graphic parameters >(axes, background etc) keeping only the actual points in lattice? (if >possible). >Tx > >On Thu, Feb 28, 2019 at 3:53 PM Duncan Murdoch ><[hidden email]> wrote: >> >> On 28/02/2019 5:39 a.m., Luigi Marongiu wrote: >> > Dear all, >> > is it possible to add points to a lattice cloud plot (3D scatter)? >I >> > can plot the main data, but what if I wanted to add another point. >In >> > R there is the high level plotting function plot(), then the low >level >> > points() or lines() etc. What is the equivalent for lattice? >> >> I don't know for sure, but I don't think you can do that in lattice. >> The scatterplot3d::scatterplot3d function returns enough information >to >> do this, but I don't think lattice::cloud does.  But even >> scatterplot3d::scatterplot3d won't necessarily get it right if points >> hide others that are behind them.  It uses the "painter's algorithm", >> and that needs everything to be drawn in just the right order, which >you >> probably won't get if you draw things in several calls. >> >> You can draw things in arbitrary order using rgl::plot3d or related >> functions, but you'll need to do more work yourself to get an array >of >> plots like lattice gives. >> >> Duncan Murdoch >> >> >> > >> > Thank you >> > >> > >> >>>> >> > >> > df = data.frame(Name = c("A", "B", "C", "D", "E"), >> >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), >> >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), >> >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), >> >                stringsAsFactors = FALSE) >> > >> > cloud(z_axis ~ x_axis * y_axis, data = df, >> >        xlab = "X", ylab = "Y", zlab = "Z", >> >        pch = 16, col = "red", type = "b", cex = 1.5, >> >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, >> >              labels=df\$Names, pos=1, offset=1, cex=0.8) >> > ) >> > >> > df2 = data.frame(Name = "F", >> >                  x_axis = 0.891, >> >                  y_axis = 2.302 >> >                  z_axis = -1.83, >> >                  stringsAsFactors = FALSE) >> > >> -- Sent from my phone. Please excuse my brevity. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: add points to lattice cloud plot (3D scatter)

 Fair enough, thank you. On Thu, Feb 28, 2019 at 4:56 PM Jeff Newmiller <[hidden email]> wrote: > > You are missing the point... lattice assembles the entire data set at once so it can adjust and synchronize all of the scales and then it generates an object that can be printed to a device. This approach is entirely incompatible with the base graphics approach of keeping global variables around that help successive functions cooperate to cumulatively build up an image. > > You need to get all your points into the lattice call initially. which may involve changing how you structure the data before you create the plot. Read the vignette and some tutorials. > > On February 28, 2019 7:38:52 AM PST, Luigi Marongiu <[hidden email]> wrote: > >I see. I have been thinking of superimposing two plots with > >par(new=TRUE), but how could I remove all the graphic parameters > >(axes, background etc) keeping only the actual points in lattice? (if > >possible). > >Tx > > > >On Thu, Feb 28, 2019 at 3:53 PM Duncan Murdoch > ><[hidden email]> wrote: > >> > >> On 28/02/2019 5:39 a.m., Luigi Marongiu wrote: > >> > Dear all, > >> > is it possible to add points to a lattice cloud plot (3D scatter)? > >I > >> > can plot the main data, but what if I wanted to add another point. > >In > >> > R there is the high level plotting function plot(), then the low > >level > >> > points() or lines() etc. What is the equivalent for lattice? > >> > >> I don't know for sure, but I don't think you can do that in lattice. > >> The scatterplot3d::scatterplot3d function returns enough information > >to > >> do this, but I don't think lattice::cloud does.  But even > >> scatterplot3d::scatterplot3d won't necessarily get it right if points > >> hide others that are behind them.  It uses the "painter's algorithm", > >> and that needs everything to be drawn in just the right order, which > >you > >> probably won't get if you draw things in several calls. > >> > >> You can draw things in arbitrary order using rgl::plot3d or related > >> functions, but you'll need to do more work yourself to get an array > >of > >> plots like lattice gives. > >> > >> Duncan Murdoch > >> > >> > >> > > >> > Thank you > >> > > >> > > >> >>>> > >> > > >> > df = data.frame(Name = c("A", "B", "C", "D", "E"), > >> >                x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754), > >> >                y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652), > >> >                z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754), > >> >                stringsAsFactors = FALSE) > >> > > >> > cloud(z_axis ~ x_axis * y_axis, data = df, > >> >        xlab = "X", ylab = "Y", zlab = "Z", > >> >        pch = 16, col = "red", type = "b", cex = 1.5, > >> >        ltext(x=df\$x_axis, y=df\$y_axis, z=df\$z_axis, > >> >              labels=df\$Names, pos=1, offset=1, cex=0.8) > >> > ) > >> > > >> > df2 = data.frame(Name = "F", > >> >                  x_axis = 0.891, > >> >                  y_axis = 2.302 > >> >                  z_axis = -1.83, > >> >                  stringsAsFactors = FALSE) > >> > > >> > > -- > Sent from my phone. Please excuse my brevity. -- Best regards, Luigi ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|