2014-09-28 96 views
7

我知道文本函数中有str参数;对我来说,能够绘制镜像字母/字符串也是很好的......任何想法?是否可以在R中绘制镜像翻转的文本?

+1

不容易我认为...你coul d可能将文本写成图像,使用ImageMagick翻转它,然后将图像文件读回... – 2014-09-28 16:39:59

+0

大多数字母在unicode中都有相应的反转表示。发现每个字母的替代unicode字符会有点挑战,但它可能比黑客镜像更容易。 – Thomas 2014-09-28 20:35:20

+0

...见http://twiki.org/cgi-bin/view/Blog/BlogEntry201211x1。虽然这很丑陋。如果你想要,你可以通过查看源代码和对应表(并重新实现R中的功能),但它非常难看/不令人满意,因为它使用了大量对称大写字母和其他* ad hoc *换人:ʜǫuoʜƚ,ylǫuyƚƚɘɿqƨ'ƚI.bɘɿoɿɿimƨƨƚƚɘƚɘƚƨʜƚ,ollɘʜ – 2014-09-28 21:56:07

回答

10

您可以用grImport玩,但它是颇为曲折

enter image description here

library(grImport) 

cat("%!PS 
/Times-Roman findfont 
100 scalefont 
setfont 
newpath 
0 0 moveto 
-1 1 scale 
(hello) show", file="hello.ps") 

PostScriptTrace("hello.ps", "hello.xml") 
hello <- readPicture("hello.xml") 
grid.newpage() 
grid.picture(hello) 
3

这里的基础上,叱咤风云的tikzDevice包,一个解决方案,由此乳胶处理字符串

library(tikzDevice) 

tikz("mirror.tex", standAlone = TRUE, height=2,width=4) 
plot(1,1, xlab="\\reflectbox{Otto and Hannah mostly won't care}") 
dev.off() 

enter image description here

相关问题