Note you can as well add marginal plots to show these distributions.
Add rug plot ggplot2.
However your rug vector has a different length from x and y so you have to specify pass some arguments into the aes to ge tthe same figure than the one you get in base r plot.
Now iam interested in creating a ggplot income distribution by retirement.
You can easily add rug on x and y axis thanks to the geom rug function to illustrate the distribution of dots.
A data frame or other object will override the plot data.
Geom rug mapping null data null.
But when i am trying rugs are note being created on the left and right side but are created only on the top and bottom.
Library library ggplot2 iris dataset head iris plot ggplot data iris aes x sepal length petal length geom point geom rug col steelblue alpha 0 1 size 1 5.
Create elegant data visualisations using the grammar of graphics.
Description usage arguments details aesthetics examples.
If you have too many points you can jitter the line positions and make them slightly thinner.
All objects will be fortified to produce a data frame.
If null the default the data is inherited from the plot data as specified in the call to ggplot.
As pointed out by csgroen geom rug is the equivalent of rug function.
Rug plots display individual cases so are best used with.
I also need to create a rugs on the left side of the plot.
By using geom rug you can add marginal rugs to your scatter plot.