Scatterplots in ggplot2
Add marginal rugs to a scatter plot
The function geom_rug() can be used :
geom_rug(sides ="bl")
sides : a string that controls which sides of the plot the rugs appear on. Allowed value is a string containing any of “trbl”, for top, right, bottom, and left.
# Add marginal rugs ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + geom_rug() # Change colors ggplot(mtcars, aes(x=wt, y=mpg, color=cyl)) + geom_point() + geom_rug() # Add marginal rugs using faithful data ggplot(faithful, aes(x=eruptions, y=waiting)) + geom_point() + geom_rug()