Porbably bug in panel.abline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Porbably bug in panel.abline

sbihorel
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Porbably bug in panel.abline

Bert Gunter-2
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 <
[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Porbably bug in panel.abline

sbihorel

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" <[hidden email]>
To: "Sebastien Bihorel" <[hidden email]>
Cc: "R-help" <[hidden email]>
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:[hidden email] | [hidden email] ] > 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:[hidden email] | [hidden email] ] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Porbably bug in panel.abline

Bert Gunter-2
hmmm...
Youre right: something subtle is occurring.

Here is a simpler reproducible example that illustrates the issue:

a <- 10
y <- x <- c(0,a)
for(k in c(-1,0,1)){
   print(xyplot(
      y~x,
      type = 'l', col="blue",
      panel = function(x,y,...){
         panel.xyplot(x,y,...)
         panel.abline(c(a+k,-1), col="red")
      }
   ))}

Somehow, the "drawable limits" seem to exclude the corners of the plotting
rectangle.

I would guess that this has something to do with how the plotting viewport
is clipped, but that's just a guess.

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 12:05 PM, Sebastien Bihorel <
[hidden email]> wrote:

>
> 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" <[hidden email]>
> *To: *"Sebastien Bihorel" <[hidden email]>
> *Cc: *"R-help" <[hidden email]>
> *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 <sebastien.bihorel@
> 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
>>
>> ______________________________________________
>> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Porbably bug in panel.abline

sbihorel
Paul Murrell posted some comments on [ https://github.com/deepayan/lattice/issues/8 | https://github.com/deepayan/lattice/issues/8 ]

----- Original Message -----
From: "Bert Gunter" <[hidden email]>
To: "Sebastien Bihorel" <[hidden email]>
Cc: "R-help" <[hidden email]>
Sent: Monday, June 18, 2018 4:15:29 PM
Subject: Re: [R] Porbably bug in panel.abline

hmmm...
Youre right: something subtle is occurring.

Here is a simpler reproducible example that illustrates the issue:

a <- 10
y <- x <- c(0,a)
for(k in c(-1,0,1)){
print(xyplot(
y~x,
type = 'l', col="blue",
panel = function(x,y,...){
panel.xyplot(x,y,...)
panel.abline(c(a+k,-1), col="red")
}
))}

Somehow, the "drawable limits" seem to exclude the corners of the plotting rectangle.

I would guess that this has something to do with how the plotting viewport is clipped, but that's just a guess.

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 12:05 PM, Sebastien Bihorel < [ mailto:[hidden email] | [hidden email] ] > wrote:




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" < [ mailto:[hidden email] | [hidden email] ] >
To: "Sebastien Bihorel" < [ mailto:[hidden email] | [hidden email] ] >
Cc: "R-help" < [ mailto:[hidden email] | [hidden email] ] >
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:[hidden email] | [hidden email] ] > wrote:

BQ_BEGIN
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:[hidden email] | [hidden email] ] 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.





BQ_END

______________________________________________
[hidden email] 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.