qhistogram | R Documentation |
This all-in-one function draws, annotates, displays and saves a histogram of a
distribution provided as a numeric vector. It is a wrapper around ggpubr::ggbarplot()
,
with the automation of many features. All ggpubr
parameters can be accessed through
the ...
argument.
qhistogram(
vec,
also.pdf = FALSE,
save.obj = FALSE,
ext = MarkdownHelpers::ww.set.file.extension(default = "png", also_pdf = also.pdf),
xlab = FALSE,
plot = TRUE,
save = TRUE,
mdlink = MarkdownHelpers::unless.specified("b.mdlink", def = FALSE),
plotname = FixPlotName(substitute(vec)),
subtitle = NULL,
suffix = NULL,
caption = suffix,
filename = NULL,
logX = FALSE,
logY = FALSE,
annotation_logticks_X = logX,
annotation_logticks_Y = logY,
vline = FALSE,
filtercol = 0,
add = "median",
palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb",
"uchicago")[4],
col = as.character(1:3)[1],
xlab.angle = 90,
hide.legend = TRUE,
max.names = 50,
grid = "y",
w = 5,
h = w,
...
)
vec |
A numeric vector for which the histogram is to be plotted. |
also.pdf |
Save plot in both png and pdf formats. |
save.obj |
Save the ggplot object to a file. Default: FALSE. |
ext |
File extension for the saved plot. Either '.pdf' or '.png'. Default is '.pdf'. |
xlab |
Label for the X-axis. By default, it uses the plot name. |
plot |
Logical indicating whether to display the plot. Default is TRUE. |
save |
Logical indicating whether to save the plot into a file. Default is TRUE. |
mdlink |
Logical indicating whether to insert .pdf and .png image links in the markdown report, set by "path_of_report". Default is FALSE. |
plotname |
Title of the plot and the name of the file (unless specified in |
subtitle |
Optional subtitle text added below the title. Default is NULL. |
suffix |
Optional suffix added to the filename. Default is NULL. |
caption |
Optional text added to bottom right corner of the plot. Default = suffix |
filename |
Optional filename for the saved plot. Default is parsed from |
logX |
Logical indicating whether to make X axis on log10 scale. Default is FALSE. |
logY |
Logical indicating whether to make Y axis on log10 scale. Default is FALSE. |
annotation_logticks_X |
Logical indicating whether to add annotation logticks on X-axis. Default follows the value of |
annotation_logticks_Y |
Logical indicating whether to add annotation logticks on Y-axis. Default follows the value of |
vline |
Numeric value at which to draw a vertical line on the plot. Default is FALSE (no line). |
filtercol |
Numeric value indicating the direction to color bars above/below the threshold. Default is 0 (no color change). |
add |
Character defining the type of plot annotations to add. Default is 'median'. |
palette_use |
Color palette to use from GGpubr. Default is 'jco'. |
col |
Color of the plot. Default is '1'. |
xlab.angle |
Angle to rotate X-axis labels. Default is 90 degrees. |
hide.legend |
Logical indicating whether to hide the legend. Default is TRUE. |
max.names |
Maximum number of names to show on the axis. Default is 50. |
grid |
Character indicating the axis to add gridlines. Options are 'x', 'y', or 'xy'. Default is 'y'. |
w |
Width of the plot. Default is 5. |
h |
Height of the plot. Default is the same as width. |
... |
Additional parameters for the corresponding plotting function. |
It returns a ggplot object if plot
is TRUE.
## Not run:
weight <- rnorm(1000)
qhistogram(vec = weight)
qhistogram(vec = weight, vline = 2, filtercol = -1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.