if the explanatory variable is numeric, this controls how it is discretized. breaks is passed to hist and can be a list of arguments.
tol.ylab
convenience tolerance parameter for y-axis annotation. If the distance between two labels drops under this threshold, they are plotted equidistantly.
off
vertical offset between the bars (in per cent). It is fixed to 0 for spinograms and defaults to 2 for spine plots.
ylevels
a character or numeric vector specifying in which order the levels of the dependent variable should be plotted.
col
a vector of fill colors of the same length as levels(y). The default is to call gray.colors.
xaxlabels, yaxlabels
character vectors for annotation of x and y axis. Default to levels(y) and levels(x), respectively for the spine plot. For xaxlabels in the spinogram, the breaks are used.
weights
numeric. A vector of frequency weights for each observation in the data. If NULL all weights are implicitly assumed to be 1. If x is already a 2-way table, the weights are ignored.
Examples
library("tinyplot")# "spineplot" type convenience stringtinyplot(Species ~ Sepal.Width, data = iris, type ="spineplot")
# Aside: specifying the type is redundant for this example, since tinyplot# default's to "spineplot" if y is a factor (just like base plot).tinyplot(Species ~ Sepal.Width, data = iris)# Use `type_spineplot()` to pass extra arguments for customizationtinyplot(Species ~ Sepal.Width, data = iris, type =type_spineplot(breaks =4))
p =palette.colors(3, "Pastel 1")tinyplot(Species ~ Sepal.Width, data = iris, type =type_spineplot(breaks =4, col = p))
rm(p)# More idiomatic tinyplot way of drawing the previous plot: use y == bytinyplot( Species ~ Sepal.Width | Species, data = iris, type =type_spineplot(breaks =4),palette ="Pastel 1", legend =FALSE)
# Grouped and faceted spineplotsttnc =as.data.frame(Titanic)tinyplot( Survived ~ Sex, facet =~ Class, data = ttnc,type =type_spineplot(weights = ttnc$Freq))
# For grouped "by" spineplots, it's better visually to facet as welltinyplot( Survived ~ Sex | Class, facet ="by", data = ttnc,type =type_spineplot(weights = ttnc$Freq))
# Fancier version. Note the smart inheritance of spacing etc.tinyplot( Survived ~ Sex | Class, facet ="by", data = ttnc,type =type_spineplot(weights = ttnc$Freq),palette ="Dark 2", facet.args =list(nrow =1), axes ="t")
# Note: It's possible to use "by" on its own (without faceting), but the# overlaid result isn't great. We will likely overhaul this behaviour in a# future version of tinyplot...tinyplot(Survived ~ Sex | Class, data = ttnc,type =type_spineplot(weights = ttnc$Freq), alpha =0.3)