l_hist
is a generic function for creating interactive histogram displays
that can be linked with loon's other displays.
l_hist(x, ...) # S3 method for default l_hist( x, yshows = c("frequency", "density"), by = NULL, on, layout = c("grid", "wrap", "separate"), connectedScales = c("cross", "row", "column", "both", "x", "y", "none"), origin = NULL, binwidth = NULL, showStackedColors = TRUE, showBinHandle = FALSE, color = l_getOption("color"), active = TRUE, selected = FALSE, xlabel = NULL, showLabels = TRUE, showScales = FALSE, showGuides = TRUE, parent = NULL, ... ) # S3 method for factor l_hist( x, showFactors = length(unique(x)) < 25L, factorLabelAngle, factorLabelSize = 12, factorLabelColor = l_getOption("foreground"), factorLabelY = 0, ... ) # S3 method for character l_hist( x, showFactors = length(unique(x)) < 25L, factorLabelAngle, factorLabelSize = 12, factorLabelColor = l_getOption("foreground"), factorLabelY = 0, ... ) # S3 method for data.frame l_hist(x, ...) # S3 method for matrix l_hist(x, ...) # S3 method for list l_hist(x, ...) # S3 method for table l_hist(x, ...) # S3 method for array l_hist(x, ...)
x | vector with numerical data to perform the binning on x, |
---|---|
... | named arguments to modify the histogram plot states or layouts, see details. |
yshows | one of "frequency" (default) or "density" |
by | loon plot can be separated by some variables into multiple panels.
This argument can take a |
on | if the |
layout | layout facets as |
connectedScales | Determines how the scales of the facets are to be connected depending
on which
|
origin | numeric scalar to define the binning origin |
binwidth | a numeric scalar to specify the binwidth
If NULL |
showStackedColors | if TRUE (default) then bars will be coloured according to colours of the points; if FALSE, then the bars will be a uniform colour except for highlighted points. |
showBinHandle | If |
color | colour fills of bins; colours are repeated
until matching the number x.
Default is found using |
active | a logical determining whether points appear or not
(default is |
selected | a logical determining whether points appear selected at first
(default is |
xlabel | label to be used on the horizontal axis. If NULL, an attempt at a meaningful label
inferred from |
showLabels | logical to determine whether axes label (and title) should be presented. |
showScales | logical to determine whether numerical scales should be presented on both axes. |
showGuides | logical to determine whether to present background guidelines to help determine locations. |
parent | a valid Tk parent widget path. When the parent widget is
specified (i.e. not |
showFactors | whether to show the factor labels (unique strings in |
factorLabelAngle | is the angle of rotation (in degrees) for the factor labels. If not specified, an angle of 0 is chosen if there are fewer than 10 labels; labels are rotated 90 degrees if there are 10 or more. This can also be a numeric vector of length equal to the number of factor labels. |
factorLabelSize | is the font size for the factor labels (default 12). |
factorLabelColor | is the colour to be used for the factor labels.
(default is |
factorLabelY | either a single number, or a numeric vector of length equal to the number of factor labels, determining the y coordinate(s) for the factor labels. |
if the argument by
is not set, a loon
widget will be returned;
else an l_facet
object (a list) will be returned and each element is
a loon
widget displaying a subset of interest.
For more information run: l_help("learn_R_display_hist")
Note that when changing the yshows
state from
'frequency'
to 'density'
you might have to use
l_scaleto_world
to show the complete histogram in the plotting
region.
Some arguments to modify layouts can be passed through,
e.g. "separate", "byrow", etc.
Check l_facet
to see how these arguments work.
Turn interactive loon plot static loonGrob
, grid.loon
, plot.loon
.
Other loon interactive states:
l_info_states()
,
l_plot()
,
l_serialaxes()
,
l_state_names()
,
names.loon()
if(interactive()){ h <- l_hist(iris$Sepal.Length) names(h) h["xlabel"] <- "Sepal length" h["showOutlines"] <- FALSE h["yshows"] h["yshows"] <- "density" l_scaleto_plot(h) h["showStackedColors"] <- TRUE h['color'] <- iris$Species h["showStackedColors"] <- FALSE h["showOutlines"] <- TRUE h["showGuides"] <- FALSE # link another plot with the previous plot h['linkingGroup'] <- "iris_data" h2 <- with(iris, l_hist(Petal.Width, linkingGroup="iris_data", showStackedColors = TRUE)) # Get an R (grid) graphics plot of the current loon plot plot(h) # or with more control about grid parameters grid.loon(h) # or to save the grid data structure (grob) for later use hg <- loonGrob(h) }