From 254d1667615cb2399566c336a2bfafddaf90089f Mon Sep 17 00:00:00 2001 From: vertesy Date: Mon, 31 Jan 2022 16:01:53 +0100 Subject: [PATCH] hide legend option added to all functions --- DESCRIPTION | 4 +-- .../Create_the_ggExpress_Package.v0.1.R | 2 +- Development/Development.bac | 34 ++++++++++++++++--- R/ggExpress.R | 34 ++++++++++++++++--- man/qboxplot.Rd | 3 ++ man/qdensity.Rd | 3 ++ man/qhistogram.Rd | 3 ++ man/qscatter.Rd | 3 ++ man/qviolin.Rd | 3 ++ 9 files changed, 78 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d6b42b9..82f6fcc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ggExpress Title: ggExpress is the fastest way to create, annotate and export plots in R -Version: 0.3.6 +Version: 0.3.7 Authors@R: person("Abel", "Vertesy", , "a.vertesy@imba.oeaw.ac.at", role = c("aut", "cre")) Author: Abel Vertesy [aut, cre] @@ -38,6 +38,6 @@ Imports: stats, tidyverse Encoding: UTF-8 -Packaged: 2022-01-16 18:56:12 +Packaged: 2022-01-31 16:01:04 Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 diff --git a/Development/Create_the_ggExpress_Package.v0.1.R b/Development/Create_the_ggExpress_Package.v0.1.R index eeddaba..979e297 100644 --- a/Development/Create_the_ggExpress_Package.v0.1.R +++ b/Development/Create_the_ggExpress_Package.v0.1.R @@ -19,7 +19,7 @@ require('Stringendo') # Setup ------------------------ PackageName = "ggExpress" -package.version = "0.3.6" +package.version = "0.3.7" setwd("~/GitHub/Packages/") RepositoryDir = kollapse("~/GitHub/Packages/", PackageName, "/") diff --git a/Development/Development.bac b/Development/Development.bac index 5c43ac0..88e164a 100644 --- a/Development/Development.bac +++ b/Development/Development.bac @@ -27,6 +27,7 @@ #' @param col Color of the plot. #' @param logX Make X axis log10-scale. #' @param logY Make Y axis log10-scale. +#' @param hide.legend hide legend #' @param max.names The maximum number of names still to be shown on the axis. #' @param w width of the plot. #' @param h height of the plot. @@ -44,6 +45,7 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl , add = "median" , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] , col = as.character(1:3)[1] + , hide.legend = TRUE , max.names = 50 , w = 5, h = w, ...) { if (isFALSE(xlab)) xlab = plotname @@ -68,6 +70,11 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (vline) p <- p + ggplot2::geom_vline(xintercept = vline) + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + + fname = Stringendo::kpp(plotname, suffix, "hist", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h) if (mdlink & save) qMarkdownImageLink(fname) @@ -90,6 +97,7 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". #' @param logX Make X axis log10-scale. #' @param palette_use GGpubr Color palette to use. +#' @param hide.legend hide legend #' @param logY Make Y axis log10-scale. #' @param max.names The maximum number of names still to be shown on the axis. #' @param w width of the plot. @@ -105,6 +113,7 @@ qdensity <- function(vec, ext = "pdf", xlab = F, plot = TRUE , save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) , logX = F, logY = F , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = TRUE , max.names = 50 , w = 5, h = w, ...) { if (isFALSE(xlab)) xlab = plotname @@ -119,6 +128,11 @@ qdensity <- function(vec, ext = "pdf", xlab = F, plot = TRUE if (length(unique(df$"names")) == 1) ggplot2::theme(legend.position = "none") if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + + fname = Stringendo::kpp(plotname, suffix, "dens", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h) if (mdlink & save) qMarkdownImageLink(fname) @@ -341,6 +355,7 @@ qpie <- function(vec = Network.Size #' @param stat.label.y.npc stat label y position #' @param stat.label.x stat label x position #' @param plot Display the plot. +#' @param hide.legend hide legend #' @param palette_use GGpubr Color palette to use. #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". @@ -365,6 +380,7 @@ qboxplot <- function(df_XYcol , stat.method = NULL, stat.label.y.npc = "top", stat.label.x = NULL # , fill = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logY = F #, logX = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -384,8 +400,9 @@ qboxplot <- function(df_XYcol # if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (stat.test) p <- p + stat_compare_means(method = stat.method, label.y.npc = stat.label.y.npc, label.x = stat.label.x, ...) - - + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } fname = Stringendo::kpp(plotname, suffix, "boxplot", Stringendo::flag.nameiftrue(logY), ext) # , Stringendo::flag.nameiftrue(logX) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) @@ -411,6 +428,7 @@ qboxplot <- function(df_XYcol #' @param stat.label.y.npc stat label y position #' @param stat.label.x stat label x position #' @param plot Display the plot. +#' @param hide.legend hide legend #' @param palette_use GGpubr Color palette to use. #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". @@ -435,6 +453,7 @@ qviolin <- function(df_XYcol , stat.method = NULL, stat.label.y.npc = "top", stat.label.x = 0.5 # , fill = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logY = F #, logX = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -455,8 +474,9 @@ qviolin <- function(df_XYcol # if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (stat.test) p <- p + stat_compare_means(method = stat.method, label.y.npc = stat.label.y.npc, label.x = stat.label.x, ...) - - + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } fname = Stringendo::kpp(plotname, suffix, "violinplot", Stringendo::flag.nameiftrue(logY), ext) # , Stringendo::flag.nameiftrue(logX) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) @@ -480,6 +500,7 @@ qviolin <- function(df_XYcol #' @param vline Draw a vertical line on the plot. #' @param plot Display the plot. #' @param palette_use GGpubr Color palette to use. +#' @param hide.legend hide legend #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". #' @param w width of the plot. @@ -495,6 +516,7 @@ qscatter <- function(df_XYcol # , title = F , col = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logX = F, logY = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -512,6 +534,10 @@ qscatter <- function(df_XYcol if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + fname = Stringendo::kpp(plotname, suffix, "scatter", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) if (mdlink & save) qMarkdownImageLink(fname) diff --git a/R/ggExpress.R b/R/ggExpress.R index 5c43ac0..88e164a 100644 --- a/R/ggExpress.R +++ b/R/ggExpress.R @@ -27,6 +27,7 @@ #' @param col Color of the plot. #' @param logX Make X axis log10-scale. #' @param logY Make Y axis log10-scale. +#' @param hide.legend hide legend #' @param max.names The maximum number of names still to be shown on the axis. #' @param w width of the plot. #' @param h height of the plot. @@ -44,6 +45,7 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl , add = "median" , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] , col = as.character(1:3)[1] + , hide.legend = TRUE , max.names = 50 , w = 5, h = w, ...) { if (isFALSE(xlab)) xlab = plotname @@ -68,6 +70,11 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (vline) p <- p + ggplot2::geom_vline(xintercept = vline) + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + + fname = Stringendo::kpp(plotname, suffix, "hist", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h) if (mdlink & save) qMarkdownImageLink(fname) @@ -90,6 +97,7 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". #' @param logX Make X axis log10-scale. #' @param palette_use GGpubr Color palette to use. +#' @param hide.legend hide legend #' @param logY Make Y axis log10-scale. #' @param max.names The maximum number of names still to be shown on the axis. #' @param w width of the plot. @@ -105,6 +113,7 @@ qdensity <- function(vec, ext = "pdf", xlab = F, plot = TRUE , save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) , logX = F, logY = F , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = TRUE , max.names = 50 , w = 5, h = w, ...) { if (isFALSE(xlab)) xlab = plotname @@ -119,6 +128,11 @@ qdensity <- function(vec, ext = "pdf", xlab = F, plot = TRUE if (length(unique(df$"names")) == 1) ggplot2::theme(legend.position = "none") if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + + fname = Stringendo::kpp(plotname, suffix, "dens", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h) if (mdlink & save) qMarkdownImageLink(fname) @@ -341,6 +355,7 @@ qpie <- function(vec = Network.Size #' @param stat.label.y.npc stat label y position #' @param stat.label.x stat label x position #' @param plot Display the plot. +#' @param hide.legend hide legend #' @param palette_use GGpubr Color palette to use. #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". @@ -365,6 +380,7 @@ qboxplot <- function(df_XYcol , stat.method = NULL, stat.label.y.npc = "top", stat.label.x = NULL # , fill = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logY = F #, logX = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -384,8 +400,9 @@ qboxplot <- function(df_XYcol # if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (stat.test) p <- p + stat_compare_means(method = stat.method, label.y.npc = stat.label.y.npc, label.x = stat.label.x, ...) - - + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } fname = Stringendo::kpp(plotname, suffix, "boxplot", Stringendo::flag.nameiftrue(logY), ext) # , Stringendo::flag.nameiftrue(logX) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) @@ -411,6 +428,7 @@ qboxplot <- function(df_XYcol #' @param stat.label.y.npc stat label y position #' @param stat.label.x stat label x position #' @param plot Display the plot. +#' @param hide.legend hide legend #' @param palette_use GGpubr Color palette to use. #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". @@ -435,6 +453,7 @@ qviolin <- function(df_XYcol , stat.method = NULL, stat.label.y.npc = "top", stat.label.x = 0.5 # , fill = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logY = F #, logX = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -455,8 +474,9 @@ qviolin <- function(df_XYcol # if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() if (stat.test) p <- p + stat_compare_means(method = stat.method, label.y.npc = stat.label.y.npc, label.x = stat.label.x, ...) - - + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } fname = Stringendo::kpp(plotname, suffix, "violinplot", Stringendo::flag.nameiftrue(logY), ext) # , Stringendo::flag.nameiftrue(logX) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) @@ -480,6 +500,7 @@ qviolin <- function(df_XYcol #' @param vline Draw a vertical line on the plot. #' @param plot Display the plot. #' @param palette_use GGpubr Color palette to use. +#' @param hide.legend hide legend #' @param save Save the plot into a file. #' @param mdlink Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". #' @param w width of the plot. @@ -495,6 +516,7 @@ qscatter <- function(df_XYcol # , title = F , col = c(NULL , 3)[1] , palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4] + , hide.legend = FALSE , ext = "png", also.pdf = T , logX = F, logY = F , hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F) @@ -512,6 +534,10 @@ qscatter <- function(df_XYcol if (logX) p <- p + ggplot2::scale_x_log10() if (logY) p <- p + ggplot2::scale_y_log10() + if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none" + , axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) ) + } + fname = Stringendo::kpp(plotname, suffix, "scatter", Stringendo::flag.nameiftrue(logX), Stringendo::flag.nameiftrue(logY), ext) if (save) qqSave(ggobj = p, title = plotname, fname = fname, ext = ext, w = w, h = h, also.pdf = also.pdf) if (mdlink & save) qMarkdownImageLink(fname) diff --git a/man/qboxplot.Rd b/man/qboxplot.Rd index d6f00b6..39e9b57 100644 --- a/man/qboxplot.Rd +++ b/man/qboxplot.Rd @@ -16,6 +16,7 @@ qboxplot( stat.label.x = NULL, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4], + hide.legend = FALSE, ext = "png", also.pdf = T, logY = F, @@ -48,6 +49,8 @@ qboxplot( \item{palette_use}{GGpubr Color palette to use.} +\item{hide.legend}{hide legend} + \item{ext}{File extension (.pdf / .png).} \item{also.pdf}{also.pdf} diff --git a/man/qdensity.Rd b/man/qdensity.Rd index 1939af7..33c2a1d 100644 --- a/man/qdensity.Rd +++ b/man/qdensity.Rd @@ -17,6 +17,7 @@ qdensity( logY = F, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4], + hide.legend = TRUE, max.names = 50, w = 5, h = w, @@ -46,6 +47,8 @@ qdensity( \item{palette_use}{GGpubr Color palette to use.} +\item{hide.legend}{hide legend} + \item{max.names}{The maximum number of names still to be shown on the axis.} \item{w}{width of the plot.} diff --git a/man/qhistogram.Rd b/man/qhistogram.Rd index 36222f7..f6cee15 100644 --- a/man/qhistogram.Rd +++ b/man/qhistogram.Rd @@ -21,6 +21,7 @@ qhistogram( palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4], col = as.character(1:3)[1], + hide.legend = TRUE, max.names = 50, w = 5, h = w, @@ -56,6 +57,8 @@ qhistogram( \item{col}{Color of the plot.} +\item{hide.legend}{hide legend} + \item{max.names}{The maximum number of names still to be shown on the axis.} \item{w}{width of the plot.} diff --git a/man/qscatter.Rd b/man/qscatter.Rd index 147b56a..5fa47ab 100644 --- a/man/qscatter.Rd +++ b/man/qscatter.Rd @@ -11,6 +11,7 @@ qscatter( col = c(NULL, 3)[1], palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4], + hide.legend = FALSE, ext = "png", also.pdf = T, logX = F, @@ -36,6 +37,8 @@ qscatter( \item{palette_use}{GGpubr Color palette to use.} +\item{hide.legend}{hide legend} + \item{ext}{File extension (.pdf / .png).} \item{also.pdf}{also.pdf} diff --git a/man/qviolin.Rd b/man/qviolin.Rd index a95dbf7..998a94e 100644 --- a/man/qviolin.Rd +++ b/man/qviolin.Rd @@ -15,6 +15,7 @@ qviolin( stat.label.x = 0.5, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4], + hide.legend = FALSE, ext = "png", also.pdf = T, logY = F, @@ -45,6 +46,8 @@ qviolin( \item{palette_use}{GGpubr Color palette to use.} +\item{hide.legend}{hide legend} + \item{ext}{File extension (.pdf / .png).} \item{also.pdf}{also.pdf}