-
Notifications
You must be signed in to change notification settings - Fork 14
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
Error in geom_half_violin: Error occurred in the 2nd layer #23
Comments
Also, I found this question in geom_half_violin(). This is my code and the error information. > p <- ggplot(count, aes(x = Type1, y = value, fill = State)) +
+ # 分面小提琴图
+ geom_half_violin(
+ data = count %>% filter(Sample == "Normal"),
+ aes(x = Type1, y = value), trim = FALSE,
+ fill = "#A9CCE3", colour = NA, side = "l", scale = 'width'
+ ) +
+ geom_half_violin(
+ data = count %>% filter(Sample == sample_label),
+ aes(x = Type1, y = value), trim = FALSE,
+ fill = "#dfb424", colour = NA, side = "r", scale = 'width'
+ ) +
+ scale_y_continuous(limits = c(0, NA)) +
+ scale_fill_manual(name = 'Sample_type',
+ breaks = c('Normal', sample_label),
+ values = c('Normal' = '#A9CCE3',sample_label = '#dfb424')) +
+ theme_bw() +
+ # 修改文本
+ theme(plot.title = element_text(size = 17, hjust = 0.5),
+ panel.background = element_blank(),
+ panel.grid.major = element_blank(),
+ panel.grid.minor = element_blank(),
+ panel.border = element_rect(size = 1),
+ axis.text.x = element_text(size = 15, angle = 45, hjust = 1, vjust = 1), # 旋转x轴文本
+ axis.text.y = element_text(size = 15),
+ axis.title = element_text(size = 15),
+ plot.margin = margin(t = 0.4, b = 0, r = 1, l = 1, unit = "cm")) +
+ labs(x = '',
+ y = 'log2(TPM)',
+ title = paste(sample_label, gene_name, collapse = " "))
Warning message:
The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
> p
Error in `geom_half_violin()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 2nd layer.
Caused by error in `if ((is_panel & (side[1] == "l")) | is_group) ...`:
! missing value where TRUE/FALSE needed
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: Groups with fewer than two datapoints have been dropped.
ℹ Set `drop = FALSE` to consider such groups for position adjustment purposes.
2: No shared levels found between `names(values)` of the manual scale and the data's fill values.
3: Removed 934 rows containing missing values or values outside the scale range (`geom_half_violin()`).
4: Removed 1350 rows containing missing values or values outside the scale range (`geom_half_violin()`).
Connected to your session in progress, last started 2024-Apr-27 12:10:01 UTC (14 minutes ago) Could you provide a solution to this question? Please let me know. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Frederik,
I ran into the following error when using
geom_half_violin()
. Could you take a look to see what went wrong? Thanks!It worked with either
geom_boxplot()
orgeom_violin()
Created on 2023-03-25 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: