Skip to content

Double coordinate transformations for geoms that draw with other geoms #2149

@has2k1

Description

@has2k1

When a geom queries the coordinate range and uses the result to create data that is then plotted by another geom, there is potentially a double transformation. i.e. coord.range() yields results in coordinate space and if followed by coord.transform(), the data may get transformed two times. Affects coords that transform the limits in coord$setup_panel_params and also do transforms in coord$transform. This includes coord_trans and coord_sf.

Affected geoms include geom_abline, geom_hline and geom_hline.

reprex

library(ggplot2)

df <- data.frame(x=1:6, y=10^(1:6))
ggplot(df, aes(x, y)) +
  geom_point() +
  geom_vline(xintercept=3, color='red') +
  coord_trans(y='log10')

The red line (at x=3) should be top to bottom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorcoord 🗺️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions