갱신 :
GGAlly 다시 업데이트 된이 대답에 해킹 또한 더 이상 작동하지 않습니다,하지만 마지막이 아닌있다 -hack 솔루션 (가 희망 미래 지향적 방법으로)
scales <- scale_colour_brewer(type = 'qual') %+% scale_fill_brewer(type = 'qual')
은 당신이 할 수 주어진
for (row in seq_len(ps$nrow))
for (col in seq_len(ps$ncol))
ps[row, col] <- ps[row, col] + scales
다른 대답에 해킹이 더 이상 작동, 그래서 새로운 하나를 해킹하지 않습니다
옛날 방식!플롯 객체의 각각의 문자열을 수정해야 플롯을 수정하기 위해
> dta <- data.frame(a=1:6, b=7:12, c=c('f', 'g'))
> ps <- ggpairs(dta, 1:2, colour = 'c')
> str(ps)
List of 10
$ data :'data.frame': 2 obs. of 3 variables:
..$ a: int [1:2] 1 2
..$ b: int [1:2] 3 4
..$ c: int [1:2] 5 6
$ columns : int [1:3] 1 2 3
$ plots :List of 9
..$ : chr "ggally_densityDiag(ggally_data, ggplot2::aes(x = a, colour = c))"
..$ : chr "ggally_cor(ggally_data, ggplot2::aes(x = b, y = a, colour = c))"
[...]
$ gg : NULL
- attr(*, "class")= chr [1:2] "gg" "ggpairs"
> ps
![plot before](https://i.stack.imgur.com/SmGdI.png)
:
ggpairs
오브젝트의 내부 구조는 데이터 세트 및 문자열의 목록 추가 명령을 포함합니다. 이를 위해, 우리는 deparse(substitute(argument))
를 사용하는 사용자가 전달 된 코드를 포함하는 문자열을 얻기 위해, 모든 플롯 호출에 추가 :
add_to_plots <- function(pairs, modification) {
str <- deparse(substitute(modification))
pairs$plots <- lapply(pairs$plots, function(s) paste(s, '+', str))
pairs
}
> add_to_plots(ps, scale_colour_brewer(type = 'qual'))
![plot after](https://i.stack.imgur.com/1sUym.png)
좋은 해킹! 바라기를 이것은 좋은 동안 안정되어 있 체재한다. –