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

plot_beeswarm retired functions #11

Closed
fontikar opened this issue Jun 15, 2021 · 1 comment
Closed

plot_beeswarm retired functions #11

fontikar opened this issue Jun 15, 2021 · 1 comment
Assignees

Comments

@fontikar
Copy link
Collaborator


author: fontikar
date: 2021-06-15
output: "reprex::reprex_document"
title: steep-carp_reprex.R

Can't convert old retired functions into their new recommended ones. Suspect it is actually a bug in scales! I have lodged an issue with them - scary stuff. This isn't super high priority because even retired functions takes a while to become completely obsolete and unusable (Wickham, useR 2021).

library(scales)
library(patchwork)

# Old retired code that needs to be updated following scales recommendations
#"parse_format() and math_format() was retired; please use label_parse() and label_math() instead"
demo_log10(x = c(0.1, 10e07),
           breaks = scales::trans_breaks("log10", function(x) 10^x),
           labels = scales::trans_format("log10", scales::math_format(10^.x)))
#> scale_x_log10(breaks = scales::trans_breaks("log10", function(x) 10^x), 
#>     labels = scales::trans_format("log10", scales::math_format(10^.x)))

#Lets do the breaks first
demo_log10(x = c(0.1, 10e07),
           breaks = trans_breaks("log10", function(x) 10^x)) #Old retired code
#> scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x))

demo_log10(x = c(0.1, 10e07),
           breaks = breaks_log(6)) #YAY easy conversion
#> scale_x_log10(breaks = breaks_log(6))

#Now the labels
demo_log10(x = c(0.1, 10e07),
           breaks = breaks_log(6), 
           labels = trans_format("log10", scales::math_format(10^.x))) #Old retired code
#> scale_x_log10(breaks = breaks_log(6), labels = trans_format("log10", 
#>     scales::math_format(10^.x)))

lab_math <- demo_log10(x = c(0.1, 10e07),
           breaks = breaks_log(6), 
           labels = scales::label_math()) #The superscript is not what is expected
#> scale_x_log10(breaks = breaks_log(6), labels = scales::label_math())

lab_number <- demo_log10(x = c(0.1, 10e07),
                       breaks = breaks_log(6), 
                       labels = scales::label_number()) #Original labels
#> scale_x_log10(breaks = breaks_log(6), labels = scales::label_number())

lab_math/lab_number

Created on 2021-06-15 by the reprex package (v2.0.0)

@fontikar fontikar self-assigned this Jun 16, 2021
@fontikar
Copy link
Collaborator Author

Using a bbolker function for now! Suggested here: r-lib/scales#311
format = log10 gives weird labels still especially if range is not very big, hard to generalise function that will also accomodate varying breaks, so this is a good solution for now! Also deals with issue #12 so I will close both!

p1 <- p1 + scale_x_log10(name="", breaks = scales::breaks_log(), labels = scientific_10, limits=c(vals$minimum, vals$maximum)) p2 <- p2 + scale_x_log10(name=paste(plant_trait_name, ' (', data$unit[1], ')'), breaks = scales::breaks_log(), labels = scientific_10, limits=c(vals$minimum, vals$maximum))

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