vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Plot not rendered correctly when using `abline` in combination with `layout`

Open mihaiconstantin opened this issue 3 years ago • 3 comments

Description

Not sure if I am missing something here, but it seems that the plot rendering is not working as expected when creating a new plot after abline in the context of a custom layout.

Reproduction

To reproduce, please run the following code:

# Seed.
set.seed(123)

# Data.
x <- rnorm(100)
y <- rnorm(100)
y_cumulative <- cumsum(y)

# Set layout.
layout(matrix(1:2, 2, 1))

# Plot daily downloads.
plot(x, y)
abline(h = mean(x))

# Plot cumulative downloads.
plot(x, y_cumulative)

# Reset layout.
layout(1:1)

plot_issue

It seems that swapping the order of the plots produces the expected output, i.e.:

# Set layout.
layout(matrix(1:2, 2, 1))

# Plot cumulative downloads.
plot(x, y_cumulative)

# Plot daily downloads.
plot(x, y)
abline(h = mean(x))

# Reset layout.
layout(1:1)

plot

Environment (please complete the following information):

  • OS: macOS
  • VSCode Version: 1.67.2
  • R Version: 4.1.2
  • vscode-R version: 2.5.0
  • httpgd version: 1.3.0

mihaiconstantin avatar May 26 '22 12:05 mihaiconstantin

@nx10 any idea?

renkun-ken avatar May 27 '22 00:05 renkun-ken

@mihaiconstantin Thanks for reporting this (and @renkun-ken thanks for the ping). I can confirm this is a bug in httpgd. It seems to be an issue with clipping. I will investigate.

nx10 avatar May 27 '22 20:05 nx10

Should be fixed now: https://github.com/nx10/httpgd/commit/ba471a11dd546ca1ab06381deb9acbef89dcad36

nx10 avatar May 28 '22 22:05 nx10

@renkun-ken , I think we can close this now then

gowerc avatar Aug 13 '22 15:08 gowerc