2

I want to show just the minimum and maximum values for all the axes of a ggpairs {GGally} plot. Find below a reproducible example

df=as.data.frame(matrix(1:1000,nrow = 100))
ggpairs(df)

enter image description here

I know I can do it individually by using breaks, but I don't know how can I apply this in ggpairs. Can somebody help me?

rm167
  • 1,185
  • 2
  • 10
  • 26
  • 2
    one way is to define your own function.... `my_fn <- function(data, mapping, ...){ ggplot(data = data, mapping = mapping, ...) + ; geom_point(...) + ; scale_y_continuous(breaks=round(range(data[,as.character(mapping$y)]))) +; scale_x_continuous(breaks=round(range(data[,as.character(mapping$x)]))) }` . Then plot `ggpairs(df, lower=list(continuous=my_fn))` . You can tweak the breaks to make more pretty values, change the density plot similarilty etc etc – user20650 Aug 18 '17 at 20:27
  • It works. Thanks. If you post this as an answer I will accept it. I guess I have to do the same for diagonal plots to adjust the axes labels of top-left and bottom-right density plots as well? – rm167 Aug 19 '17 at 11:34

0 Answers0