ggparcoord axes adjustments: remove default labels, remove extra spacing

974 Views Asked by At

I'd like to remove the default "variable" and "value" labels on the axes of ggparcoord plots:

library(GGally)
ggparcoord(data = mtcars,
           columns = c(4:5),
           groupColumn = 1,
           scale = "globalminmax",
           alphaLines = 0.2)

example ggparcoord plot

I'd also like to remove the default extra spaces on either end of the x-axis. How can I make these custom axis adjustments? Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

You can use axis.title.x (or .y) for changing the titles and expand to remove the extra white-space beyond the limits.

ggparcoord(data = mtcars,
           columns = c(4:5),
           groupColumn = 1,
           scale = "globalminmax",
           alphaLines = 0.2) +
  theme(axis.title.x=element_blank(),
        axis.title.y=element_blank()) +
  scale_x_discrete(expand = c(0.1,0.1))

I used c(0.1,0.1) to have some space beyond the limits as it would look cleaner but you can use c(0,0) for expand to remove all the spaces beyond the x limits.

enter image description here