Skip to content

scale_x_units and scale_y_units incorrectly delete rows of data #412

@JohnADawson

Description

@JohnADawson

The following code ought to show two points, at (0., 1 m) and at (0., 2 m).

data.frame(x = 0., y = units::make_units(m) * 1.) |>
  ggplot2::ggplot(ggplot2::aes(.data$x, .data$y)) +
  units::scale_y_units() +
  ggplot2::geom_point() +
  ggplot2::geom_point(data = data.frame(x = 0., y = units::make_units(km) * 0.002))

However, it does not show the second point:

Warning message:
Removed 1 row containing missing values or values outside the scale range (`geom_point()`). 
Image

Strangely, substituting 2,000 mm for 0.002 km causes the point to be shown:

data.frame(x = 0., y = units::make_units(m) * 1.) |>
  ggplot2::ggplot(ggplot2::aes(.data$x, .data$y)) +
  units::scale_y_units() +
  ggplot2::geom_point() +
  ggplot2::geom_point(data = data.frame(x = 0., y = units::make_units(mm) * 2000.))
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions