Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed #292: when the next plot is a par change compared to the previo…

…us plot, should remove the next plot but use the *previous* plot to compare to the (i+2)th plot, otherwise the previous plot will always be kept there
  • Loading branch information...
commit 3508ddb86f0068c17570b3c71dc1e79414041627 1 parent 64ead76
@yihui authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 R/plot.R
View
14 R/plot.R
@@ -141,11 +141,19 @@ rm_blank_plot = function(res) {
## merge low-level plotting changes
merge_low_plot = function(x, idx = sapply(x, is.recordedplot)) {
idx = which(idx); n = length(idx); m = NULL # store indices that will be removed
+ i1 = idx[1]; i2 = idx[2] # compare plots sequentially
for (i in 1:(n - 1)) {
- p1 = x[[idx[i]]]; p2 = x[[idx[i + 1]]]
+ p1 = x[[i1]]; p2 = x[[i2]]
if (is_low_change(p1, p2)) {
- m = c(m, if (is_par_change(p1, p2)) idx[i + 1] else idx[i])
- }
+ # if the next plot only differs with the previous plot by par() changes,
+ # remove the next plot and keep the previous fixed, otherwise remove the
+ # previous and move its index to the next plot
+ if (is_par_change(p1, p2)) r = i2 else {
+ r = i1; i1 = idx[i + 1]
+ }
+ m = c(m, r)
+ } else i1 = idx[i + 1]
+ i2 = idx[i + 2]
}
if (is.null(m)) x else x[-m]
}
Please sign in to comment.
Something went wrong with that request. Please try again.