scale_break: scale_x_break

View source: R/scales.R

scale_x_breakR Documentation

scale_x_break

Description

Set an axis break point for a 'gg' plot

Usage

scale_x_break(
  breaks,
  scales = "fixed",
  ticklabels = NULL,
  expand = TRUE,
  space = 0.1
)

scale_y_break(
  breaks,
  scales = "fixed",
  ticklabels = NULL,
  expand = TRUE,
  space = 0.1
)

Arguments

breaks

break point

scales

relative width or height of subplots, default is "fixed". If scale is 'free', all subplots have equal width or height. It also can be any number to set relative width or height compare to first subplot.

ticklabels

the axis labels to subplot, default is NULL.

expand

default is TRUE, logical or a vector of range expansion constants used to add some padding around the data to ensure that they are placed some distance away from the axes. Use the convenience function expansion() of ggplot2 to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables. If it is logical, the TRUE means the default of ggplot2 (foregoing statement), and FALSE means no expand for the plot.

space

the blank space among the subplots after break, default is 0.1 (cm).

Details

This scale function set an axis break point for a 'gg' plot. Either 'x' and 'y' axes are supported. The result is still a 'gg' object and user can progressively add layers to it.

Value

gg object

Author(s)

Guangchuang Yu

Examples

require(ggplot2 )
set.seed(2019-01-19)
d <- data.frame(
  x = 1:20,
  y = c(rnorm(5) + 4, rnorm(5) + 20, rnorm(5) + 5, rnorm(5) + 22)
)

p <- ggplot(d, aes(x, y)) + geom_col()
x <- p+scale_y_break(c(7, 17 ) )
print(x)

ggbreak documentation built on July 9, 2023, 5:50 p.m.