Skip to content

Commit

Permalink
hide legend option added to all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Jan 31, 2022
1 parent 94f432f commit 254d166
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"))
Author: Abel Vertesy <[email protected]> [aut, cre]
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Development/Create_the_ggExpress_Package.v0.1.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/")
Expand Down
34 changes: 30 additions & 4 deletions Development/Development.bac
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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".
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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".
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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)
Expand Down
34 changes: 30 additions & 4 deletions R/ggExpress.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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".
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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".
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions man/qboxplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/qdensity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/qhistogram.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/qscatter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/qviolin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 254d166

Please sign in to comment.