coord_brick()!

This commit is contained in:
Ryan Timpe
2019-07-03 16:50:01 -04:00
parent a0daf3a7bb
commit 1fb9a83c70
5 changed files with 57 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ Collate:
'bricks_from_data.R'
'bricks_to_3d.R'
'collect_bricks.R'
'coord_brick.R'
'geom_brick.R'
'geom_brick_col.R'
'geom_brick_point.R'

View File

@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand
export("%>%")
export(CoordBrick)
export(GeomBrick)
export(GeomBrickCol)
export(bricks_from_coords)
@@ -9,6 +10,7 @@ export(bricks_from_table)
export(collect_3d)
export(collect_bricks)
export(convert_to_match_color)
export(coord_brick)
export(display_3d)
export(display_bricks)
export(display_colors)

30
R/coord_brick.R Normal file
View File

@@ -0,0 +1,30 @@
#' Cartesian coordinates with fixed "aspect ratio"
#'
#' A fixed scale coordinate system forces a specified ratio between the
#' physical representation of data units on the axes. The ratio represents the
#' number of units on the y-axis equivalent to one unit on the x-axis.
#'
#' @export
#' @param ratio aspect ratio, expressed as `y / x`
#'
#' # Resize the plot to see that the specified aspect ratio is maintained
coord_brick <- function(ratio = 1, xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") {
ggproto(NULL, CoordBrick,
limits = list(x = xlim, y = ylim),
ratio = ratio,
expand = expand,
clip = clip
)
}
#' @rdname brickr-ggproto
#' @export
CoordBrick <- ggproto("CoordBrick", CoordCartesian,
is_free = function() FALSE,
aspect = function(self, ranges) {
1 * self$ratio
}
)

View File

@@ -1,8 +1,9 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom_brick.R, R/geom_brick_col.R,
% R/geom_brick_point.R, R/resizing_text_grob.R
% Please edit documentation in R/coord_brick.R, R/geom_brick.R,
% R/geom_brick_col.R, R/geom_brick_point.R, R/resizing_text_grob.R
\docType{data}
\name{GeomBrick}
\name{CoordBrick}
\alias{CoordBrick}
\alias{GeomBrick}
\alias{GeomBrickCol}
\alias{GeomStud}
@@ -11,8 +12,10 @@
\alias{preDrawDetails.resizingTextGrob}
\alias{postDrawDetails.resizingTextGrob}
\title{GeomBrick}
\format{An object of class \code{GeomStud} (inherits from \code{Geom}, \code{ggproto}, \code{gg}) of length 5.}
\format{An object of class \code{CoordBrick} (inherits from \code{CoordCartesian}, \code{Coord}, \code{ggproto}, \code{gg}) of length 3.}
\usage{
CoordBrick
GeomStud
resizingTextGrob(...)

17
man/coord_brick.Rd Normal file
View File

@@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coord_brick.R
\name{coord_brick}
\alias{coord_brick}
\title{Cartesian coordinates with fixed "aspect ratio"}
\usage{
coord_brick(ratio = 1, xlim = NULL, ylim = NULL, expand = TRUE,
clip = "on")
}
\arguments{
\item{ratio}{aspect ratio, expressed as \code{y / x}Resize the plot to see that the specified aspect ratio is maintained}
}
\description{
A fixed scale coordinate system forces a specified ratio between the
physical representation of data units on the axes. The ratio represents the
number of units on the y-axis equivalent to one unit on the x-axis.
}