I am using the package GGally (and method ggpairs) to create scatterplot matrices.
I notice that the static version (object p below) appears to have correctly-centered correlation values and densities. The image below demonstrates this -
However, the interactive version (object ggPS below) appears to have incorrectly-centered correlation values and densities. Namely, they appear to be centered at the left. The image below demonstrates this -
I wonder if there may be a good method to remedy this issue?
library(plotly)
library(GGally)
set.seed(2)
dat <- data.frame(ID = paste0("ID",1:100), A.1=sort(rnorm(100)), A.2=sort(rnorm(100)), A.3=sort(rnorm(100)), B.1=sort(rnorm(100)), B.2=sort(rnorm(100)))
dat$ID <- as.character(dat$ID)
minVal = 0
maxVal = max(dat[,-1])
my_fn <- function(data, mapping, ...){
x = data[,c(as.character(mapping$x))]
y = data[,c(as.character(mapping$y))]
p <- ggplot(data = dat, aes(x=x, y=y)) + coord_cartesian(xlim = c(minVal, maxVal), ylim = c(minVal, maxVal))
p
}
p <- ggpairs(dat[,-1], lower = list(continuous = my_fn))
ggPS <- ggplotly(p)
As a side note, I tried to use the solution posted at (GGpairs, correlation values are not aligned) by altering the syntax to create object p as follows:
p <- ggpairs(dat[,-1], lower = list(continuous = my_fn), upper = list(continuous = wrap("cor", hjust=5)))
However, this did not appear to make a difference.
Any recommendations would be most appreciated!