View source: R/position_disjoint_ranges.R
position_disjoint_ranges | R Documentation |
One-dimensional ranged data in the x-direction is segregated in the y-direction such that no overlap in two-dimensional space occurs. This positioning works best when no relevant information is plotted in the y-direction.
position_disjoint_ranges(extend = 1, stepsize = 1)
extend |
a |
stepsize |
a |
An object is considered disjoint from a second object when the range
between their xmin
and xmax
coordinates don't overlap.
Objects that overlap are assigned to different bins in the y-direction,
whereby lower bins are filled first. This way, information in the
x-direction is preserved and different objects can be discerned.
Note that this positioning is only particularly useful when y-coordinates
do not encode relevant information. Geoms that pair well with this
positioning are geom_rect()
and
ggplot2::geom_tile()
.
This positioning function was inspired by the disjointBins()
function in the IRanges
package, but has been written such that it
accepts any numeric input next to solely integer input.
A PositionDisjointRanges object.
The disjointBins
function the Bioconductor IRanges package.
# Even though geom_tile() is parametrised by middle-x values, it is
# internally converted to xmin, xmax, ymin, ymax parametrisation so the
# positioning still works.
ggplot() +
geom_tile(aes(x = rnorm(200), y = 0),
width = 0.2, height = 0.9,
position = position_disjoint_ranges(extend = 0.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.