You can easily add rug on x and y axis thanks to the geom rug function to illustrate the distribution of dots.
Ggplot add rug plot.
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.
I posted this as follow up to a sibling question with lattice i e.
Now iam interested in creating a ggplot income distribution by retirement.
Lattice s panel rug produces different line length with wide plot but due to different graphical system it deserves to be separate.
The function geom rug can be used.
If we want to add a legend to our ggplot2 plot we need to specify the colors within the aes function i e.
A data frame or other object will override the.
Create legend in ggplot2 plot.
Geom rug mapping null data null.
Description usage arguments details aesthetics examples.
A data frame or other object will override the plot data.
I also need to create a rugs on the left side of the plot.
Have a look at the following r syntax.
Adding marginal rugs to a scatter plot.
Create elegant data visualisations using the grammar of graphics.
Rug plots display individual cases so are best used with smaller datasets.
Rug plots display individual cases so are best used with.
As pointed out by csgroen geom rug is the equivalent of rug function.
Note you can as well add marginal plots to show these distributions.
It can be used to observe the marginal distributions more clearly.
By using geom rug you can add marginal rugs to your scatter plot.
A marginal rug is a one dimensional density plot drawn on the axis of a plot.
If null the default the data is inherited from the plot data as specified in the call to ggplot.
Add marginal rugs to a scatter plot.
Rug plots display individual cases so are best used with smaller datasets.
All objects will be fortified to produce a data frame.
A rug plot is a compact visualisation designed to supplement a 2d display with the two 1d marginal distributions.
The aesthetics of our ggplot2 code.
Ggplot data aes x y col group ggplot with legend geom point.
If null the default the data is inherited from the plot data as specified in the call to ggplot.
A rug plot is a compact visualisation designed to supplement a 2d display with the two 1d marginal distributions.
When producing a wide plot in ggplot2 with margins that include geom rug from ggthemes the length of the lines in rugged margins is longer in the y axis than x axis.
A string that controls which sides of the plot the rugs appear on.