The function geom rug can be used.
Ggplot add rug plot with new data.
Plot data aesthetics geometry.
If null the default the data is inherited from the plot data as specified in the call to ggplot.
Density plots can be thought of as plots of smoothed histograms.
To add a geom to the plot use operator.
A function will be called with a single argument the plot data.
Geom line for trend lines time series etc.
Add marginal rugs to a scatter plot.
The first layer contains a horizontal rug in red the second layer contains a vertical rug in blue and the third layer shows the underlying points.
Because we have two continuous variables let.
Geom boxplot for well boxplots.
On which side of the plot box the rug will be plotted.
Qualitatively the particular strategy rarely matters.
Description usage arguments details aesthetics examples.
Geom point for scatter plots dot plots etc.
We will use some common ones today including.
See fortify for which variables will be created.
Allowed value is a string containing any of trbl for top right bottom and left.
According to ggplot2 concept a plot can be divided into different fundamental parts.
The following example plot contains three layers.
The colour the ticks are plotted in.
Library library ggplot2 iris dataset head iris plot ggplot data iris aes x sepal length petal length geom point geom rug col.
Most density plots use a kernel density estimate but there are other possible strategies.
You can easily add rug on x and y axis thanks to the geom rug function to illustrate the distribution of dots.
Create elegant data visualisations using the grammar of graphics.
Ggplot2 is a powerful and a flexible r package implemented by hadley wickham for producing elegant graphics the gg in ggplot2 means grammar of graphics a graphic concept which describes plots by using a grammar.
Positive lengths give inwards ticks.
Using base graphics a density plot of the geyser duration.
Add geoms graphical representations of the data in the plot points lines bars.
Some devices will round the default width up to 1.
A data frame or other object will override the plot data.
All objects will be fortified to produce a data frame.
The line width of the ticks.
A rug plot is a compact visualisation designed to supplement a 2d display with the two 1d marginal distributions.
Normally 1 bottom or 3 top.
Note you can as well add marginal plots to show these distributions.
A string that controls which sides of the plot the rugs appear on.
The smoothness is controlled by a bandwidth parameter that is analogous to the histogram binwidth.
The principal components of every plot can.