Description Usage Arguments Value Author(s) See Also Examples
getPlotRegionNodes
gets the XML/SVG nodes
within the document which house the contents of the data regions
of the sub-plots within the R graphic.
This works for traditional and lattice plots,
and also for histograms and boxplots.
getStripNodes
gets the nodes in a lattice plot
that represent the strips above each panel.
Currently doesn't do anything!
getPlotPoints
is intended to get the
elements in the SVG document that correspond
to regular data points in the data region of the
plots/sub-plots.
getTextNodes
returns the nodes in the XML
document that correspond to text in the figure.
1 2 3 4 5 6 | getPlotRegionNodes(doc, lattice = FALSE,
hasAnnotations = lattice, addTypes = TRUE,
isRegion = isPlotRegionNew, ...)
getTextPoints(doc, ...)
getTextNodes(doc, ...)
getPlotPoints(doc, simplify = TRUE, addTypes = TRUE, ...)
|
doc |
the parsed SVG document |
lattice |
a logical value indicating whether the plot is a trellis/lattice plot. |
hasAnnotations |
whether to use a heuristic which will recognize/permit the presence of additional R-level elements (e.g. text, lines) annotations within the plot region children. |
... |
any additional parameters |
simplify |
a logical value. If this is |
addTypes |
a logical value which if |
isRegion |
the function that is used to determing if a |
getPlotRegionNodes
returns a list of the group (g) nodes which have only path children
and discards those that are the entire device region.
getStripNodes
returns a list of nodes.
Duncan Temple Lang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | doc = svgPlot({
par(mfrow = c(3, 1))
plot(mpg ~ wt, mtcars)
hist(mtcars$mpg)
plot(mpg ~ disp, mtcars)
})
plots = getPlotRegionNodes(doc)
length(plots)
doc = svgPlot(pairs(mtcars))
rr = getPlotRegionNodes(doc)
length(rr)
sapply(rr, xmlSize)
# Using layout() with 2 plots and the second as an inset in the first.
doc = svgPlot({
layout(matrix(c(1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1), 3, ))
plot(1:100)
plot(10:1)
})
rr = getPlotRegionNodes(doc)
length(rr)
sapply(rr, xmlSize)
library(lattice)
pp = svgPlot(xyplot( mpg ~ wt | am + cyl, mtcars, group = carb,
auto.key = list(columns = 4, space ="right")))
# Note that the order of the plot regions is different from that in
# the lattice/trellis object $panel.args
a = getPlotRegionNodes(pp)
lapply(a, getPlotPoints)
getPlotPoints(pp)
nodes = getLatticeLegendNodes(pp)
sapply(nodes, xmlGetAttr, "type")
# Draw a series of line segments. Note that this only appears as a
# single observation.
dd = svgPlot(plot(1:10, type = "l"))
rr = getPlotRegionNodes(dd)
xmlSApply(rr[[1]], guessSVGShape)
# Here we draw both lines and the points.
# We end up with 10 points and 10 lines all inside the same <g>
dd = svgPlot(plot(1:10, type = "b"))
rr = getPlotRegionNodes(dd)
xmlSize(rr[[1]])
xmlSApply(rr[[1]], guessSVGShape)
# Here we draw both lines and the points but separately.
# We end up with 2 "plotting regions", i.e. <g> nodes and the lines
# are in the second one.
# This plot is slightly different with the lines running through the points.
dd = svgPlot({ plot(1:10)
lines(1:10, 1:10)
})
rr = getPlotRegionNodes(dd)
length(rr)
xmlSize(rr[[1]])
xmlSize(rr[[2]])
isInside(rr[[2]], rr[[1]])
xmlSApply(rr[[2]], guessSVGShape)
# a Polyline.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.