Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggpairs upper discrete count mismatch with internal axis labels #435

Open
toddyoder opened this issue Mar 25, 2022 · 1 comment
Open

ggpairs upper discrete count mismatch with internal axis labels #435

toddyoder opened this issue Mar 25, 2022 · 1 comment

Comments

@toddyoder
Copy link

The rows of discrete count plots above the diagonal appear switched compared to their labels when using ggpairs with internal axis labels.

(df <- data.frame(SEX = c("Male", "Male", "Female", "Female"),
                  COUNTRY = c("USA", "USA", "Canada", "USA")))
#>      SEX COUNTRY
#> 1   Male     USA
#> 2   Male     USA
#> 3 Female  Canada
#> 4 Female     USA
GGally::ggpairs(df, axisLabels = "internal")

image

@N-Accumbens
Copy link

N-Accumbens commented Apr 19, 2022

I think I have a similar problem and it seems to happen based on what you plot first. There can be identical graphs with mismatched axes. The graph for the column of var3 and row var2 are the same, but their axes are reversed. This seems to be due to a conflict between count and dot_no_facet's axes plotting and which one comes first.

EDIT The individual graph is correct, it's just that when the graphs are put together that the scales no longer make sense. I've updated my reprex.

library(GGally)
#> Warning: package 'GGally' was built under R version 4.1.3
#> Loading required package: ggplot2
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2

df <- data.frame(var1 = runif(100, min = 40, max = 180),
                 var2 = rpois(100, lambda = 4))

df$var3 <- abs(20-df$var2) |> factor()            
df$var2<-factor(df$var2)
# Show how the axes aren't quite right.

paste("The graph for the column of var3 and row var2 are the same, but their axes are reversed. This seems to be due to a conflict between count and dot_no_facet's axes plotting and which one comes first")
#> [1] "The graph for the column of var3 and row var2 are the same, but their axes are reversed. This seems to be due to a conflict between count and dot_no_facet's axes plotting and which one comes first"

reversedY<-ggpairs(
  data=df,
  lower = list(discrete = "count", combo = "dot_no_facet"),
  columns = c(1,3,2),
  title = "reversed Y"
)

reversedY

reversedY[3,2]

normalY<-ggpairs(
  data=df,
  lower = list(discrete = "count", combo = "dot_no_facet"),
  columns = c(3,1,2),
  title = "normal Y"
)

normalY

normalY[3,1]

paste("reversedY[3,2] and normalY[3,1] are identical, but when the entire plot is made, it's incorrect")
#> [1] "reversedY[3,2] and normalY[3,1] are identical, but when the entire plot is made, it's incorrect"

Created on 2022-04-21 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants