Skip to content

Commit

Permalink
Allow adding events to multiple panels
Browse files Browse the repository at this point in the history
Setting 'on' to vector of panels would error because 'on' was still a
vector in the call to get_lanel(on). Thanks to Ethan Smith for the
report.

Fixes #420.
  • Loading branch information
joshuaulrich committed Jun 3, 2024
1 parent 0fdc320 commit fb9fd1e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,13 @@ addEventLines <- function(events, main="", on=0, lty=1, lwd=1, col=1, ...){
xdata <- x$Env$xdata
xsubset <- x$Env$xsubset

ypos <- x$get_panel(on)$ylim[2] * 0.995
panel <- x$get_active_panel()
if (panel$use_log_yaxis) {
ypos <- log(exp(panel$ylim_render[2]) * 0.995)
} else {
ypos <- panel$ylim_render[2] * 0.995
}

# we can add points that are not necessarily at the points on the main series
subset.range <-
paste(format(start(xdata[xsubset]), "%Y%m%d %H:%M:%OS6"),
Expand Down Expand Up @@ -985,7 +991,7 @@ addLegend <- function(legend.loc="topright", legend.names=NULL, col=NULL, ncol=1
if(is.na(on[1])){
yrange <- c(0, 1)
} else {
panel <- x$get_panel(on)
panel <- x$get_active_panel()
yrange <- panel$ylim_render
}
# this just gets the data of the main plot
Expand Down Expand Up @@ -1674,6 +1680,7 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10
replot_env$get_xlim <- get_xlim
replot_env$get_ylim <- get_ylim
replot_env$create_ylim <- create_ylim
replot_env$get_active_panel <- get_active_panel
replot_env$get_last_action_panel <- get_last_action_panel

replot_env$new_environment <- function() { new.env(TRUE, Env) }
Expand Down

0 comments on commit fb9fd1e

Please sign in to comment.