ggplot2

Add shading to a gantt chart to delineate weekends

廉价感情. 提交于 2021-02-07 07:52:24
问题 I have created a gantt chart using ggplot, code below: # load packages require("ggplot2") require("reshape2") ############################################################################### # Create list of tasks name strings. tasks <- c("Write introduction", "Parse citation data", "Construct data timeline", "Write methods", "Model formulation", "Model selection", "Write results", "Write discussion", "Write abstract and editing") # Compile dataframe of task names, and respective start and end

ggpubr: change font size of stat_compare_means Kruskal-Wallis p-values

淺唱寂寞╮ 提交于 2021-02-07 07:52:19
问题 How can I change the font size of stat_compare_means on the plot below? I.e, change the "Kruskal-Wallis, p = 1.5e-09" and the other p-values font size? I would like to use a smaller font size than the default one... Following the data example... library(ggpubr) data("ToothGrowth") compare_means(len ~ dose, data = ToothGrowth) # Visualize: Specify the comparisons I want my_comparisons <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2") ) # Plotting ggboxplot(ToothGrowth, x = "dose", y = "len",

ggplot with multiple regression lines to show random effects

对着背影说爱祢 提交于 2021-02-07 07:27:19
问题 I am aware of this and this posts. However, I don't seem to get the expected result when I try the following: The data can be loaded directly from here. The idea is that in a completely made-up data set, the levels of glucose in blood for several athletes at the completion of different races would depend on some fictitious amino acid (AAA): The call for the plot was: ggplot(df, aes(x = AAA, y = glucose, color=athletes)) + geom_point() + geom_smooth(method="lm", fill=NA) And I expected to get

How to change line properties in ggplot2 halfway in a time series?

◇◆丶佛笑我妖孽 提交于 2021-02-07 07:21:31
问题 Take the following straightforward plot of two time series from the economics{ggplot2} dataset require(dplyr) require(ggplot2) require(lubridate) require(tidyr) economics %>% gather(indicator, percentage, c(4:5), -c(1:3, 6)) %>% mutate(Y2K = year(date) >= 2000) %>% group_by(indicator, Y2K) %>% ggplot(aes(date, percentage, group = indicator, colour = indicator)) + geom_line(size=1) I would like to change the linetype from "solid" to "dashed" (and possibly also the line size ) for all points in

Is there a way to limit vline lengths in ggplot2

女生的网名这么多〃 提交于 2021-02-07 05:29:54
问题 I'm trying to show an intercept on a line graph using the ggplot vline and hline but want the lines to cease at the point of interception on the graph. Is this possible either in ggplot or is there another solution library(ggplot2) pshare <- data.frame() for (i in 1:365) { pshare <- rbind(pshare,c(i, pbirthday(i,365,coincident=3))) } names(pshare) <- c("number","probability") x25 <- qbirthday(prob = 0.25, classes = 365, coincident = 3) #61 x50 <- qbirthday(prob = 0.50, classes = 365,

What does size really mean in geom_point?

好久不见. 提交于 2021-02-07 05:23:28
问题 In both plots the points look different, but why? mya <- data.frame(a=1:100) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=seq(0.1,10,0.1))) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=1)) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ?aes_linetype_size_shape explains ... # Size examples # Should be

What does size really mean in geom_point?

心已入冬 提交于 2021-02-07 05:23:28
问题 In both plots the points look different, but why? mya <- data.frame(a=1:100) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=seq(0.1,10,0.1))) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=1)) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ?aes_linetype_size_shape explains ... # Size examples # Should be

What does size really mean in geom_point?

对着背影说爱祢 提交于 2021-02-07 05:23:08
问题 In both plots the points look different, but why? mya <- data.frame(a=1:100) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=seq(0.1,10,0.1))) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ggplot() + geom_path(data=mya, aes(x=a, y=a, colour=2, size=1)) + geom_point(data=mya, aes(x=a, y=a, colour=1, size=1)) + theme_bw() + theme(text=element_text(size=11)) ?aes_linetype_size_shape explains ... # Size examples # Should be

Reversing default scale gradient ggplot2

一曲冷凌霜 提交于 2021-02-07 05:20:44
问题 I am newbie, I am trying to desing a heat map. This is my code: ggplot(gd, aes(Qcountry, Q6_1_Q6d), order = TRUE) + geom_tile(aes(fill = prob), colour = "white") + theme_minimal() + labs( y = "Main reason for mobility", x = "Country") + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.3)) + scale_fill_gradient(name = "(%)") Which produces a perfect chart, my problem is low levels are dark blue, and higher values are light blue, which is not intuitive. Most common way to do is

Reversing default scale gradient ggplot2

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 05:16:32
问题 I am newbie, I am trying to desing a heat map. This is my code: ggplot(gd, aes(Qcountry, Q6_1_Q6d), order = TRUE) + geom_tile(aes(fill = prob), colour = "white") + theme_minimal() + labs( y = "Main reason for mobility", x = "Country") + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.3)) + scale_fill_gradient(name = "(%)") Which produces a perfect chart, my problem is low levels are dark blue, and higher values are light blue, which is not intuitive. Most common way to do is