From d467ea6db4801264cdaf9b6b507b3834f4eadb51 Mon Sep 17 00:00:00 2001 From: Joshua Ulrich Date: Fri, 13 Oct 2023 16:17:45 -0500 Subject: [PATCH] Evaluate main header and x-axis in local envir This avoids the potential to overwrite variables in 'Env' while evaluating the expression. For example, the 'main_xaxis_expr' was overwriting the 'type' value that is passed to chart.lines(). --- R/plot.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/plot.R b/R/plot.R index 4b873b1d..c413b0d0 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1059,6 +1059,7 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10 # main plot header Env$main_header_expr <- expression({ + local({ text(x = xlim[1], y = 0.98, labels = main, @@ -1081,10 +1082,12 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10 col = theme$labels, font = NULL) } + }, new.env(TRUE, Env)) }) # main plot x-axis Env$main_xaxis_expr <- expression({ + local({ # add observation level ticks on x-axis if < 400 obs. if (NROW(xdata[xsubset]) < 400) { axis(1, @@ -1135,6 +1138,7 @@ new.replot_xts <- function(panel=1,asp=1,xlim=c(1,10),ylim=list(structure(c(1,10 col = theme$labels, col.axis = theme$labels) } + }, new.env(TRUE, Env)) }) # panel functionality