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

Linetype and Color cannot go together #616

Open
tqtbui opened this issue Oct 15, 2024 · 0 comments
Open

Linetype and Color cannot go together #616

tqtbui opened this issue Oct 15, 2024 · 0 comments

Comments

@tqtbui
Copy link

tqtbui commented Oct 15, 2024

I have the same issue with the question here. I will copy and paste it here.

I want to use the ggline of the package ggpubr with 2 aesthetics. The quivalent perfectly works in geom_line but not in ggline. Let's say I have this dataset

data <- data.frame(x = seq(0,1,length.out = 100)) %>% mutate(a = x^2, b = x^3, c = (x+1)^-1, d = (x + 1)^-2) %>% pivot_longer(cols = c(a,b,c,d), names_to = 'var',values_to = 'val') %>% mutate(type = ifelse(var %in% c('a','b'), 'poly','inv'), order = ifelse(var %in% c('a','c'), 'low','high'))

Now I can use geom_line to get the plot of all.

data %>% ggplot() + geom_line(aes(x = x, y = val, linetype = type, color = order)

But using the same thing ggline

data %>% ggline(x = "x", y = "val", linetype = "type", color = "order")

produces the error

Error in purrr::pmap(): ℹ In index: 1. ℹ With name: val. Caused by error in purrr::map(): ℹ In index: 3. ℹ With name: group. Caused by error in if (is_parsable_aes(x)) ...: ! the condition has length > 1 Run rlang::last_trace() to see where the error occurred.

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