diff --git a/R/confidence_plot.groups.R b/R/confidence_plot.groups.R new file mode 100644 index 0000000..28a42b5 --- /dev/null +++ b/R/confidence_plot.groups.R @@ -0,0 +1,41 @@ +overconfidence_plot.groups <- function(data, color = blue, plot = "jitter", colorbg = blue202, name = "", export = FALSE, group) { + + require(ggplot2) + require(ggpubr) + require(RColorBrewer) + + df <- data.frame(Score = data, Class = "", Group = group) + + if(plot == "jitter") { + + bxp <- ggplot(df, aes(y = Score, color = Group, x = Group), ylim = c(0,1)) + + geom_hline(yintercept = c(0.2,0.5, 0.8), color = "black", size = 0.5, linetype = "dashed") + + geom_hline(yintercept = c(0,1), color = "black", size = 0.5, linetype="dashed") + + geom_violin(aes(fill = Group), width = 0.8) + + geom_boxplot(width=0.4, position = position_dodge(width=0.9), )+ + scale_color_manual(values = c("black", "black", "black"))+ + scale_fill_manual(values = c(rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95)), name = "")+ + theme(strip.text.y = element_text(angle = 0), + axis.ticks.x = element_blank()) + + bxp1 <- bxp + theme_pubr()+ + theme(legend.position = "none", axis.ticks.x = element_blank()) + + xlab("")+ + ylab("Overconfidence Score")+ + scale_y_continuous(breaks = c(0, 0.2, 0.5, 0.8, 1), limits = c(0,1)) + + guides(fill=guide_legend(title=""), color = "none") + + geom_jitter(color=color, size=3, alpha=0.5, width = 0.25) + + } + + if (export == TRUE) { + name <- paste(name,".pdf", sep = "") + ggsave(name, bxp1, width = 10, height = 6) + } + + return(bxp1) + + +} diff --git a/R/miscalibration_plot.groups.R b/R/miscalibration_plot.groups.R new file mode 100644 index 0000000..3e3c154 --- /dev/null +++ b/R/miscalibration_plot.groups.R @@ -0,0 +1,34 @@ +miscalibration_plot.groups <- function(miscalibration, calibrationaccuracy, + export = FALSE, name = "", group) { + + require(ggplot2) + require(ggpubr) + require(RColorBrewer) + + grey95 <- rgb(0.95, 0.95, 0.95) + + dfx <- data.frame(Score = miscalibration, Class = "", accuracy = calibrationaccuracy, Group = group) + + t1 <- ggplot(dfx, aes(x = Group, y = Score), ylim = c(-1,1)) + + geom_hline(yintercept = 0, color = "black", size = 0.5, linetype = "dashed")+ + geom_violin(aes(fill = Group), fill = grey95) +#facet_wrap(~Group)+ + geom_boxplot(width = 0.3) + + geom_jitter(width = 0.25, size = 3, aes(color = accuracy), alpha = 0.9)+ + scale_color_gradient(low = "red", high = green, limits = c(0,1), + name = "Calibration \nAccuracy\n") + + theme_pubr(legend = "right")+ + xlab("")+ + scale_y_continuous(breaks = c(-1, -0.5, 0, 0.5, 1), limits = c(-1, 1))+ + ylab("Miscalibration Score")+ + theme(strip.text.y = element_text(angle = 0), axis.ticks.x = element_blank()) + + + if (export == TRUE) { + name <- paste(name,".pdf", sep = "") + ggsave(name, t1, width = 10, height = 6) + } + + + return(t1) + +} diff --git a/R/overconfidence_plot.groups.R b/R/overconfidence_plot.groups.R new file mode 100644 index 0000000..28a42b5 --- /dev/null +++ b/R/overconfidence_plot.groups.R @@ -0,0 +1,41 @@ +overconfidence_plot.groups <- function(data, color = blue, plot = "jitter", colorbg = blue202, name = "", export = FALSE, group) { + + require(ggplot2) + require(ggpubr) + require(RColorBrewer) + + df <- data.frame(Score = data, Class = "", Group = group) + + if(plot == "jitter") { + + bxp <- ggplot(df, aes(y = Score, color = Group, x = Group), ylim = c(0,1)) + + geom_hline(yintercept = c(0.2,0.5, 0.8), color = "black", size = 0.5, linetype = "dashed") + + geom_hline(yintercept = c(0,1), color = "black", size = 0.5, linetype="dashed") + + geom_violin(aes(fill = Group), width = 0.8) + + geom_boxplot(width=0.4, position = position_dodge(width=0.9), )+ + scale_color_manual(values = c("black", "black", "black"))+ + scale_fill_manual(values = c(rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95)), name = "")+ + theme(strip.text.y = element_text(angle = 0), + axis.ticks.x = element_blank()) + + bxp1 <- bxp + theme_pubr()+ + theme(legend.position = "none", axis.ticks.x = element_blank()) + + xlab("")+ + ylab("Overconfidence Score")+ + scale_y_continuous(breaks = c(0, 0.2, 0.5, 0.8, 1), limits = c(0,1)) + + guides(fill=guide_legend(title=""), color = "none") + + geom_jitter(color=color, size=3, alpha=0.5, width = 0.25) + + } + + if (export == TRUE) { + name <- paste(name,".pdf", sep = "") + ggsave(name, bxp1, width = 10, height = 6) + } + + return(bxp1) + + +} diff --git a/R/underconfidence_plot.groups.R b/R/underconfidence_plot.groups.R new file mode 100644 index 0000000..eac8032 --- /dev/null +++ b/R/underconfidence_plot.groups.R @@ -0,0 +1,41 @@ +underconfidence_plot.groups <- function(data, color = blue, plot = "jitter", colorbg = blue202, name = "", export = FALSE, group) { + + require(ggplot2) + require(ggpubr) + require(RColorBrewer) + + df <- data.frame(Score = data, Class = "", Group = group) + + if(plot == "jitter") { + + bxp <- ggplot(df, aes(y = Score, color = Group, x = Group), ylim = c(0,1)) + + geom_hline(yintercept = c(0.2,0.5, 0.8), color = "black", size = 0.5, linetype = "dashed") + + geom_hline(yintercept = c(0,1), color = "black", size = 0.5, linetype="dashed") + + geom_violin(aes(fill = Group), width = 0.8) + + geom_boxplot(width=0.4, position = position_dodge(width=0.9), )+ + scale_color_manual(values = c("black", "black", "black"))+ + scale_fill_manual(values = c(rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95), + rgb(0.95, 0.95, 0.95)), name = "")+ + theme(strip.text.y = element_text(angle = 0), + axis.ticks.x = element_blank()) + + bxp1 <- bxp + theme_pubr()+ + theme(legend.position = "none", axis.ticks.x = element_blank()) + + xlab("")+ + ylab("Underconfidence Score")+ + scale_y_continuous(breaks = c(0, 0.2, 0.5, 0.8, 1), limits = c(0,1)) + + guides(fill=guide_legend(title=""), color = "none") + + geom_jitter(color=color, size=3, alpha=0.5, width = 0.25) + + } + + if (export == TRUE) { + name <- paste(name,".pdf", sep = "") + ggsave(name, bxp1, width = 10, height = 6) + } + + return(bxp1) + + +}