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() axes for categorical variables do not show categories much of the time. #442

Open
krivit opened this issue Jun 12, 2022 · 0 comments

Comments

@krivit
Copy link

krivit commented Jun 12, 2022

What appears to be happening is that the axes on the left-hand side and bottom of the plot matrix are taken from the nearest cell. For categorical variables, this means that left-hand axes contain frequencies from the histogram, which makes it impossible to tell which block corresponds to which category level. One can try to eye-ball it from the bottom axis, but if there is a quantitative variable there, the bottom axes become histogram frequencies, and so the category axes are lost altogether.

Since exact histogram counts are not very useful in this situation, perhaps the axes should be taken from one of the other plots? I am insufficiently well-versed in the ggplot2 API to say how.

Minimal example

library(GGally)
df <- data.frame(x = sample(letters[1:2], 100, replace=TRUE),
                 y = sample(letters[1:2], 100, replace=TRUE),
                 z = rnorm(100))

# Only categorical columns: vertical axis has frequencies, horizontal has category labels.
ggpairs(df, columns=1:2)

# Quantitative column at the end: frequencies everywhere, category labels lost.
ggpairs(df)

Created on 2022-06-12 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

1 participant