Skip to content

Documentation of arguments to guide_axis is unclear #4958

Description

@jarauh
  1. Apparently, order has to be numeric. However, this is not checked. Passing a character simply gives a warning ("NAs introduced by coercion").
  2. There is no example of order nor of position.

I tried to add a secondary axis on the same side as the primary axis as follows:

ggplot(mtcars, aes(hp, mpg)) +
  geom_point() +
  scale_y_continuous(
    sec.axis = sec_axis(trans = ~ 235.215 / ., name = "l/100 km",
                        guide = guide_axis(order = 2, position = "left")))

This leads to a warning: "Discarding guide on merge. Do you have more than one guide with the same position?" And the secondary axis is not drawn. So it seems that I did not fully understand the use of order and position yet...

Activity

  1. jarauh commented on Aug 23, 2022

    @jarauh
    Author

    See also: #4650 (comment). Where it is suggested, that the primary axis should automatically take the opposite position of the secondary axis.

  2. teunbrand commented on Sep 3, 2022

    @teunbrand
    Collaborator

    I'll incorporate an explicit type and length check for the order argument in #4879. Though I think the order argument only matters for axis guides when there are multiple guides for the same position. That makes the guide_axis() documentation a bit weird.

  3. added a commit that references this issue on Sep 4, 2022
    bfa93a4
  4. added a commit that references this issue on Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions