lims(...)xlim(...)ylim(...)
lims
, every
argument must be named.Observations not in this range will be dropped completely and not passed to any other layers. If a NA value is substituted for one of the limits that limit is automatically calculated.
# xlim xlim(15, 20)<ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale> aesthetics: x xmin xmax xend xintercept break_info: function break_positions: function breaks: waiver call: call clone: function dimension: function expand: waiver get_breaks: function get_breaks_minor: function get_labels: function get_limits: function guide: none is_discrete: function is_empty: function labels: waiver limits: 15 20 map: function map_df: function minor_breaks: waiver na.value: NA name: waiver oob: function palette: function range: <ggproto object: Class RangeContinuous, Range> range: NULL reset: function train: function super: <ggproto object: Class RangeContinuous, Range> rescaler: function reset: function scale_name: position_c train: function train_df: function trans: trans transform: function transform_df: function super: <ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale>xlim(20, 15)<ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale> aesthetics: x xmin xmax xend xintercept break_info: function break_positions: function breaks: waiver call: call clone: function dimension: function expand: waiver get_breaks: function get_breaks_minor: function get_labels: function get_limits: function guide: none is_discrete: function is_empty: function labels: waiver limits: -20 -15 map: function map_df: function minor_breaks: waiver na.value: NA name: waiver oob: function palette: function range: <ggproto object: Class RangeContinuous, Range> range: NULL reset: function train: function super: <ggproto object: Class RangeContinuous, Range> rescaler: function reset: function scale_name: position_c train: function train_df: function trans: trans transform: function transform_df: function super: <ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale>xlim(c(10, 20))<ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale> aesthetics: x xmin xmax xend xintercept break_info: function break_positions: function breaks: waiver call: call clone: function dimension: function expand: waiver get_breaks: function get_breaks_minor: function get_labels: function get_limits: function guide: none is_discrete: function is_empty: function labels: waiver limits: 10 20 map: function map_df: function minor_breaks: waiver na.value: NA name: waiver oob: function palette: function range: <ggproto object: Class RangeContinuous, Range> range: NULL reset: function train: function super: <ggproto object: Class RangeContinuous, Range> rescaler: function reset: function scale_name: position_c train: function train_df: function trans: trans transform: function transform_df: function super: <ggproto object: Class ScaleContinuousPosition, ScaleContinuous, Scale>xlim("a", "b", "c")<ggproto object: Class ScaleDiscretePosition, ScaleDiscrete, Scale> aesthetics: x xmin xmax xend break_info: function break_positions: function breaks: waiver call: call clone: function dimension: function drop: TRUE expand: waiver get_breaks: function get_breaks_minor: function get_labels: function get_limits: function guide: none is_discrete: function is_empty: function labels: waiver limits: a b c map: function map_df: function na.value: NA name: waiver palette: function range: <ggproto object: Class RangeDiscrete, Range> range: NULL reset: function train: function super: <ggproto object: Class RangeDiscrete, Range> range_c: <ggproto object: Class RangeContinuous, Range> range: NULL reset: function train: function super: <ggproto object: Class RangeContinuous, Range> reset: function scale_name: position_d train: function train_df: function transform: function transform_df: function super: <ggproto object: Class ScaleDiscretePosition, ScaleDiscrete, Scale>ggplot(mtcars, aes(mpg, wt)) + geom_point() + xlim(15, 20)Warning message: Removed 19 rows containing missing values (geom_point).
# with automatic lower limit ggplot(mtcars, aes(mpg, wt)) + geom_point() + xlim(NA, 20)Warning message: Removed 14 rows containing missing values (geom_point).
# Change both xlim and ylim ggplot(mtcars, aes(mpg, wt)) + geom_point() + lims(x = c(10, 20), y = c(3, 5))Warning message: Removed 18 rows containing missing values (geom_point).
coord_cartesian
.