geom_tallrect: ggplot2 geom with xmin and xmax aesthetics that covers the...

View source: R/z_geoms.R

geom_tallrectR Documentation

ggplot2 geom with xmin and xmax aesthetics that covers the entire y range, useful for clickSelects background elements.

Description

ggplot2 geom with xmin and xmax aesthetics that covers the entire y range, useful for clickSelects background elements.

Usage

geom_tallrect(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

aesthetic mapping

data

data set

stat

statistic mapping, defaults to identity

position

position mapping, defaults to identity

...

other arguments

na.rm

remove missing values?

show.legend

TRUE or FALSE

inherit.aes

TRUE or FALSE

Value

ggplot2 layer

Examples

if(require('data.table'))setDTthreads(1)#for CRAN.

library(animint2)

## Example: 2 plots, 2 selectors, but only interacting with 1 plot.
data(breakpoints)
only.error <- subset(breakpoints$error,type=="E")
only.segments <- subset(only.error,bases.per.probe==bases.per.probe[1])
signal.colors <- c(estimate="#0adb0a", latent="#0098ef")
breakpointError <- list(
  signal=ggplot()+
    geom_point(aes(
      position, signal),
      showSelected="bases.per.probe",
      data=breakpoints$signals)+
    geom_line(aes(
      position, signal), 
      colour=signal.colors[["latent"]],
      data=breakpoints$imprecision)+
    geom_segment(aes(
      first.base, mean, xend=last.base, yend=mean),
      showSelected=c("segments", "bases.per.probe"),
      colour=signal.colors[["estimate"]],
      data=breakpoints$segments)+
    geom_vline(aes(
      xintercept=base),
      showSelected=c("segments", "bases.per.probe"),
      colour=signal.colors[["estimate"]],
      linetype="dashed",
      data=breakpoints$breaks),
  error=ggplot()+
    geom_vline(aes(
      xintercept=segments), 
      clickSelects="segments",
      data=only.segments, lwd=17, alpha=1/2)+
    geom_line(aes(
      segments, error, group=bases.per.probe),
      clickSelects="bases.per.probe",
      data=only.error, lwd=4))
animint2dir(breakpointError)

animint2 documentation built on Nov. 22, 2023, 1:07 a.m.