Skip to content

Regression with width aesthetic in documentation #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gfiumara opened this issue Nov 14, 2016 · 7 comments
Closed

Regression with width aesthetic in documentation #1904

gfiumara opened this issue Nov 14, 2016 · 7 comments
Labels
bug an unexpected problem or unintended behavior layers 📈

Comments

@gfiumara
Copy link
Contributor

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

@hadley
Copy link
Member

hadley commented Jan 14, 2017

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))

@hadley hadley added bug an unexpected problem or unintended behavior layers 📈 labels Jan 25, 2017
@hadley
Copy link
Member

hadley commented Jan 27, 2017

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

@has2k1
Copy link
Contributor

has2k1 commented Jan 27, 2017

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

@hadley
Copy link
Member

hadley commented Jan 27, 2017

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

@yutannihilation
Copy link
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)

@yutannihilation
Copy link
Member

Fixed by this commit: a11f786

@lock
Copy link

lock bot commented Aug 13, 2019

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/

@lock lock bot locked and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior layers 📈
Projects
None yet
Development

No branches or pull requests

4 participants