plotly Multiple
Generates multiple plotly graphics, driven by specs in a data frame
plotlyM( data, x = ~x, y = ~y, xhi = ~xhi, yhi = ~yhi, htext = NULL, multplot = NULL, strata = NULL, fitter = NULL, color = NULL, size = NULL, showpts = !length(fitter), rotate = FALSE, xlab = NULL, ylab = NULL, ylabpos = c("top", "y"), xlim = NULL, ylim = NULL, shareX = TRUE, shareY = FALSE, height = NULL, width = NULL, nrows = NULL, ncols = NULL, colors = NULL, alphaSegments = 1, alphaCline = 0.3, digits = 4, zeroline = TRUE )
data |
input data frame |
x |
formula specifying the x-axis variable |
y |
formula for y-axis variable |
xhi |
formula for upper x variable limits ( |
yhi |
formula for upper y variable limit ( |
htext |
formula for hovertext variable |
multplot |
formula specifying a variable in |
strata |
formula specifying an optional stratification variable |
fitter |
a fitting such as |
color |
|
size |
|
showpts |
if |
rotate |
set to |
xlab |
x-axis label. May contain html. |
ylab |
a named vector of y-axis labels, possibly containing html (see example below). The names of the vector must correspond to levels of the |
ylabpos |
position of y-axis labels. Default is on top left of plot. Specify |
xlim |
2-vector of x-axis limits, optional |
ylim |
2-vector of y-axis limits, optional |
shareX |
specifies whether x-axes should be shared when they align vertically over multiple plots |
shareY |
specifies whether y-axes should be shared when they align horizontally over multiple plots |
height |
height of the combined image in pixels |
width |
width of the combined image in pixels |
nrows |
the number of rows to produce using |
ncols |
the number of columns to produce using |
colors |
the color palette. Leave unspecified to use the default |
alphaSegments |
alpha transparency for line segments (when |
alphaCline |
alpha transparency for lines used to connect points |
digits |
number of significant digits to use in constructing hovertext |
zeroline |
set to |
Generates multiple plotly
traces and combines them with plotly::subplot
. The traces are controlled by specifications in data frame data
plus various arguments. data
must contain these variables: x
, y
, and tracename
(if color
is not an "AsIs" color such as ~ I('black')
), and can contain these optional variables: xhi
, yhi
(rows containing NA
for both xhi
and yhi
represent points, and those with non-NA
xhi
or yhi
represent segments, connect
(set to TRUE
for rows for points, to connect the symbols), legendgroup
(see plotly
documentation), and htext
(hovertext). If the color
argument is given and it is not an "AsIs" color, the variable named in the color
formula must also be in data
. Likewise for size
. If the multplot
is given, the variable given in the formula must be in data
. If strata
is present, another level of separate plots is generated by levels of strata
, within levels of multplot
.
If fitter
is specified, x,y coordinates for an individual plot are
run through fitter
, and a line plot is made instead of showing data points. Alternatively you can specify fitter='ecdf'
to compute and plot emirical cumulative distribution functions.
plotly
object produced by subplot
Frank Harrell
## Not run: set.seed(1) pts <- expand.grid(v=c('y1', 'y2', 'y3'), x=1:4, g=c('a', 'b'), yhi=NA, tracename='mean', legendgroup='mean', connect=TRUE, size=4) pts$y <- round(runif(nrow(pts)), 2) segs <- expand.grid(v=c('y1', 'y2', 'y3'), x=1:4, g=c('a', 'b'), tracename='limits', legendgroup='limits', connect=NA, size=6) segs$y <- runif(nrow(pts)) segs$yhi <- segs$y + runif(nrow(pts), .05, .15) z <- rbind(pts, segs) xlab <- labelPlotmath('X<sub>12</sub>', 'm/sec<sup>2</sup>', html=TRUE) ylab <- c(y1=labelPlotmath('Y1', 'cm', html=TRUE), y2='Y2', y3=labelPlotmath('Y3', 'mm', html=TRUE)) W=plotlyM(z, multplot=~v, color=~g, xlab=xlab, ylab=ylab, ncols=2, colors=c('black', 'blue')) W2=plotlyM(z, multplot=~v, color=~I('black'), xlab=xlab, ylab=ylab, colors=c('black', 'blue')) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.