Skip to content

Regression with width aesthetic in documentation #1904

Closed

Description

@gfiumara

A warning is omitted when using the width aesthetic, but still seems to produce identical plots.

Example from ggplot2 documentation for geom_tile:
2.1 Documentation, Dev Documentation

library(ggplot2)
df <- data.frame(
  x = rep(c(2, 5, 7, 9, 12), 2),
  y = rep(c(1, 2), each = 5),
  z = factor(rep(1:5, each = 2)),
  w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
)
ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = z, width = w), colour = "grey50")

ggplot2 2.2:

Warning: Ignoring unknown aesthetics: width

ggplot2 2.1:

No output

Activity

  1. hadley commented on Jan 14, 2017

    @hadley
    Member

    And

    library(tidyverse)
    
    df <- tibble(
      x = c("F1","F2","Overall"),
      y = c(0.4,0.5,0.42), 
      w = c(1,1,2) * 0.5
    )
    
    ggplot(df, aes(x, y)) + 
      geom_col(aes(width=w))
  2. added
    bug
    on Jan 25, 2017
  3. hadley commented on Jan 27, 2017

    @hadley
    Member

    This is trickier than I thought. I think the key is that width and height are alternative parameterisations for these geoms — they're not necessary, but the setup_data() method will use them if available. It seems like adding a new alternative_aes should fix this, but when I plumb it up, setting the width as an aesthetic no longer works.

    When I come back to this, I have work in local "alternative-aes" branch

  4. has2k1 commented on Jan 27, 2017

    @has2k1
    Contributor

    Isn't that what the "slightly hacky" extra_params is for? It is not properly checked against for the case of aesthetic mappings.

    grep -r extra_params
  5. hadley commented on Jan 27, 2017

    @hadley
    Member

    @has2k1 that's subtly different, I think, and I suspect wiring it up with parameters will have the same problems.

  6. yutannihilation commented on Feb 14, 2019

    @yutannihilation
    Member

    This issue seems fixed already. Can we close this?

    library(ggplot2)
    df <- data.frame(
      x = rep(c(2, 5, 7, 9, 12), 2),
      y = rep(c(1, 2), each = 5),
      z = factor(rep(1:5, each = 2)),
      w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
    )
    ggplot(df, aes(x, y)) +
      geom_tile(aes(fill = z, width = w), colour = "grey50")

    Created on 2019-02-14 by the reprex package (v0.2.1)

  7. yutannihilation commented on Feb 14, 2019

    @yutannihilation
    Member

    Fixed by this commit: a11f786

  8. lock commented on Aug 13, 2019

    @lock

    This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

  9. locked and limited conversation to collaborators on Aug 13, 2019
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

    buglayers 📈

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions