R & Inkscape: text labels in SVG graphics exported from R did not recognized as a text in Inkscape -


i constructed dendrogram in r code:

data(iris)  aver<-sapply(iris[,-5],function(x) by(x,iris$species,mean)) matrix<-dist(aver)  clust<-hclust((matrix),"ave") clust$labels<-row.names(aver) plot(as.dendrogram(clust)) 

i wanted save dendrogram svg file using code:

install.packages("cairo") library(cairo)  svg("plot.svg") plot(as.dendrogram(clust)) dev.off() 

here problem started:

when imported "plot.svg" inkscape (ver: 0.48.4) , selected label (e.g. "setosa") not recognized text, rather "user defined" object. specifically, when selected "letter" in label , inspect xml editor (ctrl+shift+x) in inkscape obtained information:

    **id**: use117      **x**: 142.527344      **xlink:href**: #glyph0-8      **y**: 442.589844 

on other hand, when manually wrote "setosa" using "create , edit text objects" tool, , inspected in xml editor, returned:

    **id**: text4274      **sodipodi:linespacing**: 125%      **style**: font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:palatino linotype;-inkscape-font-specification:palatino linotype       **transform**: scale(0.8,0.8)       **x**: 176.02016       **xml:space**: preserve       **y**: 596.96674 

it inkscape did not recognize labels text according attribute "id" xml editor. hence, not able change neither font, size use other functions related text objects in inkscape.

here svg file, made previous code , imported inkscape

i checked previous steps using other versions of inkscape r, same.

here question:

do have suggestion how can gather labels text attribute instead of "user defined" (or whatever object...) when importing svg files r inkscape?

update

@baptiste linked so thread @oscar perpiñán suggested 3 packages (gridsvg, svgannotation , rsvgtipsdevice) manipulate svg. unfortunately, neither of packages suggested solve problem text issue. far found so thread @mo sander suggested rsvgdevice package since can preserve text object rather glyphs. being stuck rsvgdevice installation procedure, found rsvgdevice available 32-bit installations , r < 2.15.0. otherwise, r returned warning message:

warning message: package ‘rsvgdevice’ not available (for r version 3.0.1)  

beside requirements older r versions, rsvgdevice can preserve text object in svg.

this failing in cairo. major, point of view.

the cairo svg surface (i.e. back-end in cairo used "draw" on svg) not support "text" tag. not understand strings @ all. instead, places each character (glyph) individually. svg generated cairo not useful if want post-process contained text vector editor. :(

the mention found on cairo list one:

http://lists.cairographics.org/archives/cairo/2011-february/021777.html


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -