-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09da940
commit 15e7b8e
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|
||
} |