xts icon indicating copy to clipboard operation
xts copied to clipboard

Points added to new panel when par(mfrow()) is set

Open lompoc42 opened this issue 7 years ago • 4 comments

#The code below worked, prior to me upgrading from xts version 0.9-7 to 0.10-0, to produce a single panel with two plots, points overlaid onto each. Now each time points() is called it takes up the next row on the panel instead.

Example 1

par(mfrow=c(2,1))

dates = as.Date((Sys.Date()-49):Sys.Date())

v1 =  xts(rnorm(1:50), dates)
v2 = ifelse(v1>mean(v1),v1,NA)

plot(v1, type = 'l')
points(v2, pch = 16, cex = 1)

v3 =  xts(rnorm(1:50), dates)
v4 = ifelse(v3>mean(v3),v3,NA)

plot(v3, type = 'l')
points(v4, pch = 16, cex = 1)

Overlaying the points on a single plot still works fine.

Example 2

dev.off()
dates = as.Date((Sys.Date()-49):Sys.Date())

v1 =  xts(rnorm(1:50), dates)
v2 = ifelse(v1>mean(v1),v1,NA)

plot(v1, type = 'l')
points(v2, pch = 16, cex = 1)

When not using xts, the code still works to produce the desired result. See below:

Example 3: Desired Result

dev.off()
par(mfrow=c(2,1))

v1 =  rnorm(1:50)
v2 = ifelse(v1>mean(v1),v1,NA)

plot(v1, type = 'l')
points(v2, pch = 16, cex = 1)

v3 = rnorm(1:50)
v4 = ifelse(v3>mean(v3),v3,NA)

plot(v3, type = 'l')
points(v4, pch = 16, cex = 1)

It is my preference to build plots in layers. If I'm not able to do that anymore, how can I still produce my desired result?

lompoc42 avatar Aug 22 '17 15:08 lompoc42

Not sure what you mean by "yesterday's rollout". I'm assuming you mean you upgraded from xts version 0.9-7 to 0.10-0. This issue was supposedly addressed in #84. We might have a regression bug. We'll investigate.

joshuaulrich avatar Aug 22 '17 15:08 joshuaulrich

Apologies, I edited my post to reflect the correct information.

lompoc42 avatar Aug 22 '17 15:08 lompoc42

It looks like the issue is with par(mfrow=c(2,1)). The code works as expected with the default mfrow values. The issue could be in xts:::current_panel() and/or xts:::current_actions().

joshuaulrich avatar Aug 22 '17 15:08 joshuaulrich

Hello I just would like to know if this issue has been solved, and if so :

  1. where I could get the corrected source code for plot.xts, lines (.xts ?) and points (.xts ?) ?
  2. when in your roadmap you could post your new package version onto the CRAN repository ?

xts package is very useful for me, thanks a lot ! Nota : this new version (10.0), compared to previous one (0.99...) might be sometimes a little tricky when trying to reproduce "graphs that worked before - and don't work anymore", but I'm sure it's full of good ideas.

Another question : Are "additive panels" sizes (for instance height) customisable ?

Thanks again Best regards, E.

ericliret avatar Nov 29 '17 15:11 ericliret