Hi, I recently encountered situations in which reference lines are not drawn with the lattice panel.abline function. Please, consider the following example code: require(lattice) a <- runif(1,0,100) data <- data.frame(x=c(0,a^2), y=c(0,a^2)) xyplot( y~x, data = data, type = 'l', panel = function(x,y,...){ panel.xyplot(x,y,...) panel.abline(c(a^2,-1.0), col=2) } ) Adding noise (eg panel.abline(c(a^2+0.01,-1.0), col=2)) or adding some axis limits seems to bypass the problem. The problem also happens for different data source and abline coefficients: data <- data.frame(x=c(18,81), y=c(18,81)) ... panel.abline(c(99,-1.0), col=2) Thank you in advance for your feedback. Sebastien PS: the problem was also posted at https://github.com/deepayan/lattice/issues/8
Note that: xyplot( y~x, data = data, type = 'l', col="blue", panel = function(x,y,...){ panel.xyplot(x,y,...) panel.abline(c(a^2-1,-1), col="red") } ) works. The problem is a^2 is just above the "drawable" y axis limit (it is the intercept of the line at x=0 with slope -1, of course). This also explains all your other comments. Cheers, Bert -- Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jun 18, 2018 at 11:01 AM, Sebastien Bihorel < sebastien.bihorel at cognigencorp.com> wrote:> Hi, > > I recently encountered situations in which reference lines are not drawn > with the lattice panel.abline function. Please, consider the following > example code: > > > require(lattice) > > a <- runif(1,0,100) > data <- data.frame(x=c(0,a^2), y=c(0,a^2)) > > xyplot( > y~x, > data = data, > type = 'l', > panel = function(x,y,...){ > panel.xyplot(x,y,...) > panel.abline(c(a^2,-1.0), col=2) > } > ) > > Adding noise (eg panel.abline(c(a^2+0.01,-1.0), col=2)) or adding some > axis limits seems to bypass the problem. > > The problem also happens for different data source and abline > coefficients: > data <- data.frame(x=c(18,81), y=c(18,81)) > ... > panel.abline(c(99,-1.0), col=2) > > > Thank you in advance for your feedback. > > Sebastien > > PS: the problem was also posted at https://github.com/deepayan/ > lattice/issues/8 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
No, the intercept a^2 f the abline is exactly the upper limit of the data, so it is in the range. From: "Bert Gunter" <bgunter.4567 at gmail.com> To: "Sebastien Bihorel" <sebastien.bihorel at cognigencorp.com> Cc: "R-help" <r-help at r-project.org> Sent: Monday, June 18, 2018 2:28:21 PM Subject: Re: [R] Porbably bug in panel.abline Note that: xyplot( y~x, data = data, type = 'l', col="blue", panel = function(x,y,...){ panel.xyplot(x,y,...) panel.abline(c(a^2-1,-1), col="red") } ) works. The problem is a^2 is just above the "drawable" y axis limit (it is the intercept of the line at x=0 with slope -1, of course). This also explains all your other comments. Cheers, Bert -- Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jun 18, 2018 at 11:01 AM, Sebastien Bihorel < [ mailto:sebastien.bihorel at cognigencorp.com | sebastien.bihorel at cognigencorp.com ] > wrote: Hi, I recently encountered situations in which reference lines are not drawn with the lattice panel.abline function. Please, consider the following example code: require(lattice) a <- runif(1,0,100) data <- data.frame(x=c(0,a^2), y=c(0,a^2)) xyplot( y~x, data = data, type = 'l', panel = function(x,y,...){ panel.xyplot(x,y,...) panel.abline(c(a^2,-1.0), col=2) } ) Adding noise (eg panel.abline(c(a^2+0.01,-1.0), col=2)) or adding some axis limits seems to bypass the problem. The problem also happens for different data source and abline coefficients: data <- data.frame(x=c(18,81), y=c(18,81)) ... panel.abline(c(99,-1.0), col=2) Thank you in advance for your feedback. Sebastien PS: the problem was also posted at [ https://github.com/deepayan/lattice/issues/8 | https://github.com/deepayan/lattice/issues/8 ] ______________________________________________ [ mailto:R-help at r-project.org | R-help at r-project.org ] mailing list -- To UNSUBSCRIBE and more, see [ https://stat.ethz.ch/mailman/listinfo/r-help | https://stat.ethz.ch/mailman/listinfo/r-help ] PLEASE do read the posting guide [ http://www.r-project.org/posting-guide.html | http://www.R-project.org/posting-guide.html ] and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]