Skip to content
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

geom_function does not produce a x axis title where no data is added #5647

Open
davidhodge931 opened this issue Jan 15, 2024 · 5 comments
Open
Labels
layers 📈 tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@davidhodge931
Copy link

library(tidyverse)

p <- ggplot() +
  geom_function(
    fun = \(x) dnorm(x),
  )

#currently produces this
p

#I think it should produce this
p +
  labs(x = "x")

Created on 2024-01-16 with reprex v2.1.0

@davidhodge931 davidhodge931 changed the title geom_function() does not produce a x axis title where no data is added geom_function does not produce a x axis title where no data is added Jan 15, 2024
@teunbrand
Copy link
Collaborator

I think this is intended behaviour: as there is no variable that maps to the x aesthetic, there is no label to deduce from the way the plot is setup.

@davidhodge931
Copy link
Author

But there is no y aesthetic, but that axis gets a title?? It doesn't seem consistent

@teunbrand
Copy link
Collaborator

The y aesthetic is a mapping in StatFunction$default_aes, which is why it gets a title.

@davidhodge931
Copy link
Author

A function graph is used to show how x relates to y. So I think regardless of the internals that it should have a title

@teunbrand
Copy link
Collaborator

I think the required change would be in this line:

default_aes = aes(y = after_scale(y)),

We may just add x = NULL to have x automatically pop up as the default label.

@teunbrand teunbrand added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
layers 📈 tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

2 participants