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

percent_format default accuracy not ideal for axis labeling #192

Closed
kuriwaki opened this issue Dec 8, 2018 · 0 comments
Closed

percent_format default accuracy not ideal for axis labeling #192

kuriwaki opened this issue Dec 8, 2018 · 0 comments

Comments

@kuriwaki
Copy link

kuriwaki commented Dec 8, 2018

I often use labels = percent in ggplot axes to make percentages explicit, which has been very helpful.

In scales v0.5.0, the default led to rounding the axes labels to whole number percentages (0%, 25%, 50%, ) but in v1.0.0 those get rounded as 0.0%, 25.0%, 50.0%, which is inefficient. Is this intended behavior, and if so what's the best way to set percent_format(accuracy = 1) as default without typing each time?

scales v0.5.0 seemed to be able to differentiate rounding in axes vs. rounding in values. In the example below, v0.5.0 had rounded the axes to whole numbers, but retained accuracy = 0.1 in the text labels, which seemed like the right defaults.

library(tidyverse)
library(scales)
#> 
#> Attaching package: 'scales'
#> The following object is masked from 'package:purrr':
#> 
#>     discard
#> The following object is masked from 'package:readr':
#> 
#>     col_factor


vals <- rbeta(10, 1, 1)
df <- tibble(x = sample(vals), y = sample(vals))

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = percent(y)), nudge_y = 0.02) +
  scale_x_continuous(labels = percent)  +
  scale_y_continuous(labels = percent)

Created on 2018-12-08 by the reprex package (v0.2.1)

@hadley hadley closed this as completed in 16a08e4 Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant