plot_hist | R Documentation |
plot histogram of data
jj_plot_hist(
data,
feature = NULL,
fill = NULL,
thres = NULL,
colour = NULL,
group = NULL,
title = "",
nbins = 50,
size = 1,
exclude_zeros = FALSE,
include_summary = c("n", ">=", "<", ">0<"),
...
)
feature |
vector with values to plot |
fill |
optional value threshold, for which the number of observations are counted above and below |
thres |
Value threshold used to fill the histogram. Also used to count the number of observations above and below in |
colour |
optional title |
group |
xlab text |
title |
colours for bars above and below threshold |
nbins |
NULL (do not plot numbers) or vector containing any combination of 1 (observations above threshold), 2 (observations below threshold) and 3 (observations below threshold that are not 0) |
size |
border size for the histogram stacks |
exclude_zeros |
if TRUE, omit all 0 values from the plot (useful e.g. to plot sparse gene expression) |
include_summary |
Above the plot, include the number of observations within some ranges. Vector with the possibilties c('n','>=', '<', '>0<'), where n is the total number of observations, >= and < are those above and below the threshold and >0< are those greater than zero, but below the threshold |
df = data.frame(letters = sample(letters[1:4], 100, replace = T),
groups = paste0('G_', sample(1:2, 100, replace = T)),
treatment = factor(sample(c('no','yes'), 100, replace = T, prob = c(0.9,0.1)), levels=c('yes','no')),
values = sample(c(rep(0, 20), rnorm(80, 4, 2))))
jj_plot_hist(df$values)
jj_plot_hist(df, feature = 'values', group = 'groups')
jj_plot_hist(df, feature = 'values', group = 'groups', fill = 'letters', nbins = 30)
jj_plot_hist(df, feature = 'values', colour='treatment', fill = 'letters', title='my title', group = 'groups', size = 1.3, binwidth = 0.4) +
scale_fill_manual(values = jj_get_jj_colours(df$letters)) + scale_colour_manual(values = c(yes='black', no = "white"))
jj_plot_hist(df, feature = 'values', thres = 4)
jj_plot_hist(df, feature = 'values', thres = 4, exclude_zeros = T, include_summary = c('<', '>='))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.