groupByPch(SVGAnnotation)
groupByPch()所属R语言包:SVGAnnotation
Group multiple SVG paths corresponding to same plotting character
集团多个相同的绘图字符对应的SVG路径
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Typically, there is one SVG <path> element for each observation displayed in a plotting region. However, there are 10 different plotting characters in R that are made up multiple line segments and so give rise to multiple <path> elements in the resulting SVG output. To work with these more easily and sanely, it is convenient to convert the multiple path objects into a single group object for each such "point" in the display. This function does precisely that.
通常情况下,有一个SVG的<path>在绘图区域中显示每个观察的元素。不过,也有10个不同的策划研发是由多个线段,并因此引起多个<path>元素在生成的SVG输出的字符。使用这些更容易和三立,很方便的转换成单组对象为每个这样的“点”中显示多个路径对象。正是此功能。
Note that is very difficult for us in this package to be able to infer the plotting character for a point except for in the most trivial of cases. That is why we have made this function available so that those who have contextual knowledge of the plot can perform this regrouping.
请注意,这是非常困难的,在这个包,我们可以推断出一个点,除了在最平凡的情况下绘制的字符。这就是为什么我们有此功能可以使那些有图的背景知识,可以执行这个重组。
We collect the nodes related to the same observation and put them into a new <g> node and replace these nodes with that in the orginal parent node. We also add both a pch attribute to the <g> node which identifies to which pch value the new <g> corresponds and the type = 'plot-point' attribute-value pair.
我们收集有关相同的观察节点和它们放入一个新的<g>节点,并取代在原价的父节点,这些节点。我们还添加了一个pch属性<g>节点标识PCH值新的<g>对应type = 'plot-point'属性 - 值对的。
The number of line segments/path elements for each plotting character is available in the variable numPathElementsPerPCH.
线段/为每个绘图字符的路径元素的数量是在变量numPathElementsPerPCH可用。
用法----------Usage----------
groupByPch(nodes, pch)
参数----------Arguments----------
参数:nodes
the set of nodes corresponding to the observations, including some <path> elements that correspond to the same observation.
节点相应的意见,包括一些<path>的元素对应到相同的观察。
参数:pch
the vector of values specified via the pch command to generate the plot in R that corresponds to these nodes, i.e. there may be different commands and different pch vectors for different subplots.
通过指定pch命令生成R中的图,这些节点对应的值的向量,即有可能是不同的命令,并为不同的次要图的PCH向量。
值----------Value----------
The main result is the reorganization of the nodes. The return value is an integer vector that provides the grouping of the original nodes. The names indicate the plotting character from which the original node came.
主要的结果是重组的节点。返回值是一个整数的向量,提供原始节点的分组。的名字,表示从原来的节点来绘制字符。
作者(S)----------Author(s)----------
Duncan Temple Lang
参见----------See Also----------
getPlotRegionNodes
getPlotRegionNodes
See http://www.omegahat.org/SVGAnnotation/pch.svg for an example of how we collapsed the plotting characters into groups. The code to create this is below.
看到我们如何坍塌成组绘制的字符,例如http://www.omegahat.org/SVGAnnotation/pch.svg~~V。以下代码来创建。
举例----------Examples----------
pch = c(7, 8, 10)
pp = svgPlot(plot(1:10, pch = pch))
rr = getPlotRegionNodes(pp)[[1]]
xmlSize(rr)
pts = getPlotPoints(pp)
length(pts)
groupByPch(pts, pch)
xmlSize(rr)
# Note that pts is irrelevant now.[请注意,分是现在无关。]
# We need to fetch it again[我们需要再次取]
pts = getPlotPoints(pp)
###########[##########]
doc = svgPlot(plot(1:26, pch = 0:25, bg = c("red")))
rr = getPlotRegionNodes(doc)[[1]]
v = groupByPch(xmlChildren(rr), 0:25)
# now how many are remaining?[现在有多少剩余?]
xmlSize(rr)
# size of all the nodes. 0's correspond to path elements.[所有节点的大小。 0的对应路径元素。]
xmlSApply(rr, xmlSize)
# how many are in each of the g's[多少克的]
sapply(rr[names(rr) == "g"], xmlSize)
# check the pch attribute[检查PCH属性]
sapply(rr[names(rr) == "g"], xmlAttrs)
saveXML(doc, "pch.svg")
################[###############]
pch = c(8,0, 3)
doc = svgPlot(plot(1:10, pch = pch))
rr = getPlotRegionNodes(doc)[[1]]
pts = getPlotPoints(doc)
xmlSize(rr)
groupByPch(pts, pch)
xmlSize(rr)
xmlSApply(rr, xmlSize)
sapply(rr[names(rr) == "g"], xmlSize)
names(rr)
sapply(rr[names(rr) == "g"], xmlAttrs)
xmlSApply(rr, function(x) "type" %in% names(xmlAttrs(x)))
xmlSApply(rr, xmlGetAttr, "pch")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|