You re almost there you just need to add inherit aes false to your geom rug call.
Ggplot2 add rug.
You want to add marginal rugs to a scatter plot.
Ggplot2 is a system for declaratively creating graphics based on the grammar of graphics you provide the data tell ggplot2 how to map variables to aesthetics what graphical primitives to use and it takes care of the details.
A string that controls which sides of the plot the rugs appear on.
Add marginal rugs to a scatter plot.
You can easily add rug on x and y axis thanks to the geom rug function to illustrate the distribution of dots.
Marginal rug added to a scatter plot 5 10 3 discussion.
Ggplot faithful aes x eruptions y waiting geom point geom rug figure 5 28.
Plotly is a free and open source graphing library for r.
If null the default the data is inherited from the plot data as specified in the call to ggplot.
Rug plots display individual cases so are best used with smaller datasets.
Allowed value is a string containing any of trbl for top right bottom and left.
X to draw a rug along the x axis one short line for each x value y to draw a rug along the y axis one short line for each y value size default.
Otherwise the default setup ggplot tries to combine the aesthetics in geom rug with the default aesthetics from ggplot you had two different things both named n and i think that in this case that means the y axis limits were set based on all the ns which obviously results in the wrong scale for the.
A marginal rug plot is essentially a one dimensional scatter plot that can be used to visualize the distribution of data on each axis.
A data frame or other object will override the.
Typically these are a ggplot2 aesthetics to be set with attribute value b ggplot2 aesthetics to be mapped with attribute expression or c attributes of the layer as a whole which are set with attribute value.
0 5 line width of the rug s lines.
Note you can as well add marginal plots to show these distributions.
The function geom rug can be used.
We recommend you read our getting started guide for the latest installation or upgrade instructions then move on to our plotly fundamentals tutorials or dive straight in to some basic charts tutorials.
Library library ggplot2 iris dataset head iris plot ggplot data iris aes x sepal length petal length geom point geom rug col.
Stat identity default position adjustment.
A string that controls which sides of the plot the rugs appear on.