Skip to content

Changing position value in scale_ interacts strangely with coord_trans() #4551

Closed

Description

@courtiol

Applying any transformation using coord_trans() modifies what the argument position does in scale_:
(notice that only the title of the axis is sent to the top and no longer the labels when coord_trans() is used)

library(ggplot2)
  
packageVersion("ggplot2")  ## note: current devel does also behave in the same way
#> [1] '3.3.5'

ggplot(data = iris) +
  geom_point(aes(y = Sepal.Length, x = Species)) +
  scale_x_discrete(position = "top")

ggplot(data = iris) +
  geom_point(aes(y = Sepal.Length, x = Species)) +
  scale_x_discrete(position = "top") +
  coord_trans(y = "identity")

Created on 2021-07-08 by the reprex package (v2.0.0)

The same goes for the left/right positions.

Activity

  1. teunbrand commented on Jul 8, 2021

    @teunbrand
    Collaborator

    This might be related to #3959, but because "Species" is on top it would suggests that facets are aware of the position but coords might not be.

  2. thomasp85 commented on Oct 28, 2021

    @thomasp85
    Member

    Potentially also related to #4650

  3. added
    bug
    on Oct 28, 2021
  4. thomasp85 commented on Nov 17, 2021

    @thomasp85
    Member

    @paleolimbot all of these issues seems to be related to the fact that only coord_cartesian()was moved over to the new axis guide generation pipeline... are you up for moving the remaining coords?

  5. yutannihilation commented on Jul 7, 2022

    @yutannihilation
    Member

    This will be fixed by #3972.

    devtools::load_all("~/GitHub/ggplot2/")
    #> ℹ Loading ggplot2
    
    ggplot(data = iris) +
      geom_point(aes(y = Sepal.Length, x = Species)) +
      scale_x_discrete(position = "top") +
      coord_trans(y = "identity")

    Created on 2022-07-08 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugguides 📏

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions