Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(add_lines)
export(calculate_timing)
export(check_quality)
export(convplot)
export(coord_stack)
export(geom_token)
export(geom_turn)
export(GeomToken)
Expand All @@ -17,3 +18,5 @@ export(theme_turnPlot)
export(tokenize)
import(ggplot2)
import(viridis)
importFrom(ggplot2,Geom)
importFrom(ggplot2,ggproto)
26 changes: 26 additions & 0 deletions R/coord-stack.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Coordinate system that stacks a wide plot to multiple layers
#'
#' @param width Width of the stacked layers in seconds
#' @export
#' @inheritParams ggplot2::coord_trans
coord_stack <- function(width, ...) {
width <- width * 1000 # convert to ms
ggplot2::coord_trans(x = stacking_x_axis(width), ...)
}


stacking_x_axis <- function(width){
force(width)
trans <- function(x) {
x <- x %% width
x
}

scales::trans_new(
name = "stackx",
transform = trans,
inverse = function(x){
x/width
}
)
}
5 changes: 2 additions & 3 deletions R/geom_token.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ geom_token <- function(data, mapping = NULL,

#' GeomToken
#'
#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @rdname ggproto
#' @importFrom ggplot2 ggproto Geom
#' @export
GeomToken <- ggproto(
"GeomToken", Geom,
Expand Down
5 changes: 2 additions & 3 deletions R/geom_turn.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ geom_turn <- function(mapping = NULL, data = NULL,

#' GeomTurn
#'
#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @rdname ggproto
#' @importFrom ggplot2 ggproto Geom
#' @export
GeomTurn <- ggproto(
"GeomTurn", Geom,
Expand Down
14 changes: 14 additions & 0 deletions man/coord_stack.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions man/ggplot2-ggproto.Rd

This file was deleted.

23 changes: 23 additions & 0 deletions man/ggproto.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.