找回密码
 注册
查看: 366|回复: 0

R语言 RSVGTipsDevice包 RSVGTipsDevice()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-28 22:32:18 | 显示全部楼层 |阅读模式
RSVGTipsDevice(RSVGTipsDevice)
RSVGTipsDevice()所属R语言包:RSVGTipsDevice

                                        A SVG Graphics Driver with dynamic tips
                                         一个SVG图形驱动程序与动态提示

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This package contains a SVG (Scalable Vector Graphics) device that will write to a file.  The SVG shapes have optional tooltips and/or hyperlinks.  The resulting SVG files should conform the W3C Scalable Vector Graphics (SVG) standard (with the possible exception of toolTipMode=2) and do display correctly in the SVG viewer in Mozilla Firefox under Windows (XP) and Linux (Ubuntu).
这个套件包含了SVG(可伸缩矢量图形)设备,将写入到一个文件中。 SVG形状具有可选的工具提示和/或连结。 SVG文件应符合W3C的可伸缩矢量图形(SVG)标准(有可能是个例外toolTipMode=2)和SVG浏览器在Mozilla Firefox中正确显示在Windows(XP)和Linux(Ubuntu的)。


Details

详细信息----------Details----------

This graphics device supplies the underlying functions that are called by plot, lines, etc, and the following functions that are called by the user to access the special capabilities of the SVG device:
此图形设备提供了基本的功能,被称为plot,lines“等,和被称为用户访问的SVG装置的特殊功能以下功能:

devSVGTipsOpen an SVG device
devSVGTips打开SVG装置

setSVGShapeToolTipSet a tool tip to be used for the next graphics shape or text drawn
setSVGShapeToolTip设置要用于下一个图形绘制的形状或文本的工具尖端

setSVGShapeURLSet a URL to be used in the hyperlink for the next graphics shape or text drawn
setSVGShapeURL设置中要使用的超链接的URL,用于下一个图形绘制的形状或文本

getSVGToolTipModeGet the tool tip mode used by the current graphics device
getSVGToolTipMode获取工具提示当前图形设备的使用模式


(作者)----------Author(s)----------



This driver is a modification by Tony Plate <a href="mailto:tplate@acm.org">tplate@acm.org</a> of the RSvgDevice driver written by T Jake Luciani
<a href="mailto:jakeluciani@yahoo.com">jakeluciani@yahoo.com</a>




参见----------See Also----------

Design and future possible features of the RSVGTips device.
设计和未来可能的功能的RSVGTips设备。

pictex, postscript, Devices.
pictex,postscript,Devices。


实例----------Examples----------


library("RSVGTipsDevice")
sessionInfo()
devSVGTips("svgplot1.svg", toolTipMode=1,
    title="SVG example plot 1: shapes and points, tooltips are title + 1 line")
plot(c(0,10),c(0,10), type="n", xlab="x", ylab="y",
    main="Example SVG plot with title + 1 line tips (mode=1)")
setSVGShapeToolTip(title="A rectangle", desc="that is yellow")
rect(1,1,4,6, col='yellow')
setSVGShapeToolTip(title="1st circle with title only")
points(5.5,7.5,cex=20,pch=19,col='red')
setSVGShapeToolTip(title="A triangle", desc="big and green")
polygon(c(3,6,8), c(3,6,3), col='green')
# no tooltips on these points[在这些问题上没有工具提示]
points(2:8, 8:2, cex=3, pch=19, col='black')
# tooltips on each these points[每个这些点上的工具提示]
invisible(sapply(1:7, function(x)
{setSVGShapeToolTip(title=paste("point", x))
points(x+1, 8-x, cex=3, pch=1, col='black')}))
setSVGShapeToolTip(title="Text", desc="can have a tool tip too!")
text(x=4, y=9, lab="Poke me!", col="blue")
dev.off()

devSVGTips("svgplot2.svg", toolTipMode=2,
    title="SVG example plot 2: shapes and points, tooltips are title + 2 lines")
getSVGToolTipMode()
setSVGShapeToolTip(title="First circle title only")
plot(1:3, cex=10, main="Example SVG plot with title + 2 line tips (mode=2)")
setSVGShapeToolTip(title="A rectangle", desc="with a 1 line tip")
rect(1,1,2,2)
setSVGShapeToolTip(title="second circle", desc1="first line of description", desc2="second line of description")
points(1.5,2.5,cex=20,pch=19,col='red')
dev.off()

devSVGTips("svgplot3.svg", toolTipMode=2,
    title="SVG example plot 3: shapes, tooltips are title + 2 lines")
plot(c(0,10),c(0,10), type="n", xlab="x", ylab="y",
    main="Example SVG plot, tooltips are title + 2 lines (mode=2)")
setSVGShapeToolTip(title="A rectangle", desc="that is yellow")
rect(1,1,4,6, col='yellow')
setSVGShapeToolTip(title="1st circle", desc1="1st line of description",
    desc2="2nd line of description")
points(5.5,7.5,cex=20,pch=19,col='red')
setSVGShapeToolTip(title="A triangle", desc1="green", desc2="big")
polygon(c(3,6,8), c(3,6,3), col='green')
# no tooltips on these points[在这些问题上没有工具提示]
points(2:8, 8:2, cex=3, pch=19, col='black')
# tooltips on each of these points[上每一个点的工具提示]
invisible(sapply(1:7, function(x)
{setSVGShapeToolTip(title=paste("point", x))
points(x+1, 8-x, cex=3, pch=1, col='black')}))
dev.off()

devSVGTips("svgplot4.svg", title="SVG example plot 4: points and no tooltips")
plot(1:11,(-5:5)^2, type='b', main="Simple Example Plot with no tooltips")
dev.off()

devSVGTips("svgplot5.svg",
    title="SVG example plot 5: points and a rectangle, no tooltips")
plot(1:3)
rect(1,1,2,2)
dev.off()

devSVGTips("svgplot6.svg",
    title="SVG example plot 6: supply XML code for tips (title + 1 line)")
setSVGShapeContents("<title>first circle</title>")
plot(1:3, cex=10)
setSVGShapeContents("<title>hah!</title>")
rect(1,1,2,2)
setSVGShapeContents("<title>second circle</title><desc>description</desc>")
points(1.5,2.5,cex=20,pch=19,col='red')
dev.off()

devSVGTips("svgplot7.svg", toolTipMode=2,
    title="SVG example plot 7: supply XML code for tips (title + 2 lines)")
setSVGShapeContents("<title>first circle</title>")
plot(1:3, cex=10)
setSVGShapeContents("<title>hah!</title>")
rect(1,1,2,2)
setSVGShapeContents("<title>second circle</title><desc1>first line of description</desc1><desc2>second line of description</desc2>")
points(1.5,2.5,cex=20,pch=19,col='red')
dev.off()

devSVGTips("svgplot8.svg", toolTipMode=1,
    title="SVG example plot 8: tooltips + hyperlink")
plot(c(0,10),c(0,10), type="n", xlab="x", ylab="y",
    main="Example SVG plot with title + 1 line tips (mode=1) + hyperlink")
setSVGShapeToolTip(title="A rectangle", desc="that is yellow")
rect(1,1,4,6, col='yellow')
setSVGShapeToolTip(title="1st circle with title only")
points(5.5,7.5,cex=20,pch=19,col='red')
setSVGShapeToolTip(title="A triangle", desc="big and green")
polygon(c(3,6,8), c(3,6,3), col='green')
# no tooltips on these points[在这些问题上没有工具提示]
points(2:8, 8:2, cex=3, pch=19, col='black')
# tooltips on each these points[每个这些点上的工具提示]
invisible(sapply(1:7, function(x)
{setSVGShapeToolTip(title=paste("point", x))
points(x+1, 8-x, cex=3, pch=1, col='black')}))
# Hyperlink to www.r-project.org[超链接www.r-project.org]
setSVGShapeToolTip(title="www.r-project.org", desc="click to visit!")
setSVGShapeURL("http://www.r-project.org")
rect(8,6,10,7, col='blue')
# Hyperlink to www.r-project.org that opens in a new browser window or tab[www.r-project.org的超链接将在新的浏览器窗口或选项卡中打开]
setSVGShapeToolTip(title="www.r-project.org", desc="click to visit in a new page!")
setSVGShapeURL("http://www.r-project.org", "_blank")
rect(8,8,10,9, col='green')
dev.off()

devSVGTips("svgplot9.svg", toolTipMode=1,
    title="SVG example plot 9: line and point types")
plot(c(0,20),c(0,5), type="n", xlab="x", ylab="y",
    main="Example SVG plot with different line and point types")
for (i in 0:16) {
    lines(i+(0:4), (1:5), col=max(i,1), pch=i, lty=i, type="b")
    text(i, 0.5, lab=as.character(i), cex=2^(abs((i-8)/4)-1))
}
dev.off()

# This example checks encoding of characters that are special in XML: # &lt;&amp;'\"&gt; [本示例检查编码的XML的特殊字符:#<&“\”>]
# To avoid tripping up people who have already used the XML entity[为了避免绊倒人已经使用了XML实体]
# (e.g., "&amp;amp"), an ampersand followed by lower-case letters and a[(例如,“AMP”),一个符号,然后由小写字母和]
# semicolon is NOT encoded.[分号不进行编码。]
devSVGTips("svgplot10.svg", toolTipMode=1,
    title="SVG example plot 10: shapes and points, tooltips are title + 1 line, special chars")
plot(c(0,10),c(0,10), type="n", xlab="x", ylab="y",
    main="Example SVG plot with title + 1 line tips <mode=1>")
setSVGShapeToolTip(title="A rectangle", desc="that is <yellow> &amp;amp; yellow")
rect(1,1,4,6, col='yellow')
setSVGShapeToolTip(title="1st circle with title only")
points(5.5,7.5,cex=20,pch=19,col='red')
setSVGShapeToolTip(title="A triangle", desc="big &amp; green")
polygon(c(3,6,8), c(3,6,3), col='green')
text(lab="Special chars: <&amp;'\">", 6, 9, adj=0, cex=1.3)
text(lab="Already encoded: &amp;lt;&amp;amp;&amp;gt;", 6, 9.5, adj=0, cex=1.3)
# no tooltips on these points[在这些问题上没有工具提示]
points(2:8, 8:2, cex=3, pch=19, col='black')
# tooltips on each these points[每个这些点上的工具提示]
invisible(sapply(1:7, function(x)
{setSVGShapeToolTip(title=paste("<point ", x, ">", sep=""))
points(x+1, 8-x, cex=3, pch=1, col='black')}))
dev.off()

# This example checks that the fontwidth information is accurate[这个例子检查,fontwidth的信息是准确的]
# by drawing a box closely around letters.[紧紧围绕字母绘制一个框。]
# Compare appearance to other devices if you want to make things[比较外观到其他设备,如果你想要做的事情]
# more accurate.  Note that some descenders and ascenders will go[更准确。需要注意的是一些会伸和伸]
# outside of the bounds.  This info is in src/devSVG.c:charwidth.[的范围之外。这个信息是在src / devSVG.c:charwidth的。]
devSVGTips("svgplot11.svg", toolTipMode=0, title="SVG example plot 11: text width with cex=1")
charbysize0 &lt;- "'ijlIJ,./\\|:;f!\"()[]rt-*?FLTYcksxyzv`_0123456789EKPRXabdeghnopqu{}\177$ wABCSVDGHNOQUZ#&amp;+&lt;=&gt;MW^~%@m"[&+ <=> MW ^~%@ M“]
allchars    &lt;- " !\"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177"[]
charbysize <- paste(c(charbysize0, setdiff(strsplit(allchars, NULL)[[1]], strsplit(charbysize0, NULL)[[1]])), collapse="")
textinbox <- function(x, y, i) {
  cc <- substring(charbysize, i-31, i-31)
  # cc &lt;- rawToChar(as.raw(i))[CC < -  rawToChar(as.raw(I))]
  lab <- paste(rep(cc,10), collapse="")
  w <- strwidth(lab)
  if (cc==" ")
      lab <- paste(lab, "<", sep="")
  text(x, y, lab=lab, adj=c(0))
  rect(x, y-strheight(lab)/2, x+w, y+strheight(lab)/2)
}
par(mar=c(0,0,0,0))
plot(y=c(0,25),x=c(0,4), type="n", axes=FALSE, xlab="", ylab="")
text(2,25,"Character metric info: box is drawn around strings using strwidth &amp; strheight")
for (i in 32:127) textinbox(x=0.1+(i-32)%/%24, y=24-(i-32)%%24, i)
# print(data.frame(letters, strwidth(letters)))[打印(数据框(字母(字母),strwidth))]
dev.off()

# This example checks that the character alignment information is[这个例子检查字符对齐信息]
# accurate.[准确的。]
devSVGTips("svgplot12.svg", toolTipMode=0, title="SVG example plot 12: character alignment", height=6, width=6)
par(mar=c(0,0,0,0))
plot(y=c(-5,5),x=c(-10,10), type="n", axes=FALSE, xlab="", ylab="")
text(0,4.5,"Character alignment using adj= or pos= in text()")
text(0,4,"Text is drawn at red '+' using args shown")
text(0,3.5,lab="XXX")
points(0,3.5,pch=3,col='red')
for (xadj in (0:2)/2) {
  text(-3+6*(1-xadj),3,paste("X adj=", xadj," X",sep=""),adj=xadj)
  points(-3+6*(1-xadj),3,pch=3,col='red')
}
for (pos in 1:4) {
    text(c(0,-1,0,1)[pos], 1.5+0.5*c(-1,0,1,0)[pos], paste("X pos=", pos, " X", sep=""), pos=pos)
    points(c(0,-1,0,1)[pos], 1.5+0.5*c(-1,0,1,0)[pos], pch=3, col='red')
}
for (xadj in (0:2)/2)
  for (yadj in (0:2)/2) {
    text(6*(0.5-xadj),-1.5+(1-yadj),paste("X adj=", xadj,",",yadj," X",sep=""),adj=c(xadj,yadj))
    points(6*(0.5-xadj),-1.5+(1-yadj),pch=3,col='red')
  }
dev.off()

# This example shows what happens with text clipping.[这个例子显示了剪切文本会发生什么。]
# Too much clipping occurs!  I think is is not calling[太多的削波发生!我认为这是不要求]
# the text method for the device whenever the text might[该设备的文本的方法时,文本可能]
# be a little out-of-bounds (because of the setting[有一点边界(因为设定]
# dd-&gt;canClip=FALSE in src/devSVG.c).  It seems to be too[DD-> canClip = FALSE在src / devSVG.c的的)。它似乎是太]
# aggressive about this, e.g., when par(xpd=NA) (xpd=NA[主动,例如,当参数(XPD = NA)(XPD = NA]
# means clip to device region, xpd=TRUE means clip to[剪辑设备区,XPD = TRUE表示剪辑]
# figure region, and xpd=FALSE means clip to plot region).[数字区域,和XPD = FALSE表示剪辑绘制的区域)。]
devSVGTips("svgplot13.svg", toolTipMode=0, title="SVG example plot 13: character clipping", height=6, width=6)
par(xpd=FALSE)
par(mfrow=c(2,2))
par(mar=c(5, 4, 4, 2) + 0.1)
str <- paste(letters[c(1:6,21:26)],collapse="")
plot(y=c(-10,10),x=c(-10,10), type="n", xlab="X axis", ylab="Y axis",
     main=paste("par(xpd=", par("xpd"), ")", sep=""))
text(0,2,paste("clip to", switch(as.character(par("xpd")),"NA"="device","TRUE"="figure","FALSE"="plot"), "region"))
text(-9,9,str,srt=45)
text(9,0,str,srt=0)
text(9,9,str,srt=-45)
text(0,-9,str,srt=-90)
text(9,-9,str,srt=-135)
text(-9,0,str,srt=180)
text(-9,-9,str,srt=135)
text(0,9,str,srt=90)
par(xpd=TRUE)
plot(y=c(-10,10),x=c(-10,10), type="n", xlab="X axis", ylab="Y axis",
     main=paste("par(xpd=", par("xpd"), ")", sep=""))
text(0,2,paste("clip to", switch(as.character(par("xpd")),"NA"="device","TRUE"="figure","FALSE"="plot"), "region"))
text(-9,9,str,srt=45)
text(9,0,str,srt=0)
text(9,9,str,srt=-45)
text(0,-9,str,srt=-90)
text(9,-9,str,srt=-135)
text(-9,0,str,srt=180)
text(-9,-9,str,srt=135)
text(0,9,str,srt=90)
par(xpd=NA)
plot(y=c(-10,10),x=c(-10,10), type="n", xlab="X axis", ylab="Y axis",
     main=paste("par(xpd=", par("xpd"), ")", sep=""))
text(0,2,paste("clip to", switch(as.character(par("xpd")),"NA"="device","TRUE"="figure","FALSE"="plot"), "region"))
text(-9,9,str,srt=45)
text(9,0,str,srt=0)
text(9,9,str,srt=-45)
text(0,-9,str,srt=-90)
text(9,-9,str,srt=-135)
text(-9,0,str,srt=180)
text(-9,-9,str,srt=135)
text(0,9,str,srt=90)
par(xpd=FALSE)
dev.off()


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-27 22:41 , Processed in 0.028698 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表