Ggplot(my.df.long, aes(x=variable, y=vals)) + If I plot this using base R boxplot(), everything is fine boxplot(my.df, log="x", horizontal=T)īut with ggplot, my.df.long <- melt(my.df, value.name = "vals") Panel.background = element_rect(fill = "#00000000"),Ī = element_line(colour = 'black'),Ī'm trying to create a horizontal boxplot with logarithmic axis using ggplot2. # Fix the plot theme to be similar to ggboxplot Scale_shape_manual(values = c('mean' = 8, 'data' = 16)) + # Use scale_shape_manual to change shape into something i like. Geom_point(data = function(.data)filter(.data, stat = 'mean'), # Add mean to the point and change shape into something we like. Geom_jitter(data = function(.data)filter(.data, stat = 'data'), # Note that to only plot a subset I pass a function to data that "filters" the data. # Setup data with mean instead of using stat_summaryīind_cols(stat = factor(rep('mean', 3))) %>%īind_cols(stat = rep('data', nrow(mtcars)))) %>% Using the mtcars dataset as an example (and dplyr for piping) we can obtain something very similar to ggboxplot library(ggplot2)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |