Closed hadley closed 8 years ago
Hi, I'm active. Not working on RSVGDevice right now : I've only fixed some bugs and enable UTF-8 labels. If someone propose a fix, I'll publish it on cran.
Hi everybody
@mdecorde, what are your thoughts on rvg
package regarding to RSVGDevice?
Here is where are differences:
Also rvg
(for R Vector Graphics) is also supposed to provide improved versions of devices for MS Word and MS PPTX graphics (regarding to ReporteRs).
David
I think there needs to be a basic (but complete) svg driver device for R, and that's important regardless of the additional features (like interactivity). I'm not sure if it's possible to separate basic & interactive svg into separate packages, but I personally think adding interactivity via svg is fundamentally a hack (in the sense of a pragmatic solution to a complex problem), and I'm not that interested in working on it. I do want an svg device driver that just works, and produces reasonably compact output so I can switch from png to svg for web graphics. I am willing to put some time into that.
I wonder if it's worth pulling out the font metrics stuff into a separate package so multiple device drivers can use it?
I'd love to help also and strongly agree with @hadley that a good, solid svg
dev is a huge gap in R
. One feature that I'd like is g
grouping by layer or type. Is that possible? In my mind, the scripting, interactivity, etc. should all be separate from the dev
.
One big issue with assigning id
is if we combine the output in a single dom
we are likely to conflict. class
or random id
will be a much better identifier.
:+1: to klr and hadley's comments
I don't think neither we can separate the basic and the interactive instructions... This is how GraphicsDevice.h and GraphicsEngine.h works. (I agree, what I did can be considered as an hack but it's useful and fun).
I never did it but I think it should be possible to call some C code from a library located in another package (is it?). If it is possible, having the font metrics stuff into a separate package would be useful. It would help for graphics and for reporting (measure the exact size of a cell given the font size and the margins for example).
A compact version is possible, here is what I already noticed:
defs
tag is a possible solution to make file smaller also@timelyportfolio it's not possible at the graphics device level - all the information has already been lost. You probably want gridSVG.
@davidgohel calling C code from another package is fairly easy, unless you use Rcpp, in which case it's incredibly easy
For rasters, I think the right thing to do is embed a base64 encoded url in an <image>
.
Thanks for the link (and for all the work...), that's very useful. About rasters, I think Cairo can also be used to create the base64 string.
OK, so what next? I can share/modify my code, I can also fix RSVGDevice and push fixes to @mdecorde. I am also interesting in having a font metrics package. What were your thoughts on who would do the work? (I am also willing to work on that but don't want to spend time on something you are working on).
Could you work on the fontmetrics package? (And maybe a package for making a png for a raster image)?
I'll work on updating RSvgDevice, integrating the changes you've made for rvg. I'll make sure to export the C functions, so you can reuse as much as possible in rvg.
@hadley, maybe I'm just not understanding your response, but with the old svg
, we get this plus some helpful meta information. How does it produce the g
grouping?
library(ggplot2)
tf <- tempfile()
svg(tf,height=8,width =12)
ggplot(data.frame(x=1:10),aes(x=x,y=x))+geom_point()
dev.off()
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="864pt" height="576pt" viewBox="0 0 864 576" version="1.1"><defs><g><symbol overflow="visible" id="glyph0-0"><path style="stroke:none;" d="M 4.832031 -0.8125 L 4.832031 0 L 0.289063 0 C 0.28125 -0.203125 0.316406 -0.398438 0.390625 -0.585938 C 0.503906 -0.894531 0.6875 -1.199219 0.945313 -1.5 C 1.195313 -1.796875 1.5625 -2.140625 2.046875 -2.539063 C 2.789063 -3.148438 3.296875 -3.636719 3.5625 -3.996094 C 3.824219 -4.351563 3.953125 -4.6875 3.957031 -5.011719 C 3.953125 -5.339844 3.835938 -5.621094 3.597656 -5.855469 C 3.355469 -6.082031 3.042969 -6.199219 2.664063 -6.203125 C 2.253906 -6.199219 1.929688 -6.078125 1.6875 -5.835938 C 1.441406 -5.589844 1.316406 -5.25 1.316406 -4.824219 L 0.449219 -4.914063 C 0.507813 -5.558594 0.730469 -6.050781 1.121094 -6.390625 C 1.503906 -6.726563 2.023438 -6.894531 2.679688 -6.898438 C 3.335938 -6.894531 3.859375 -6.714844 4.246094 -6.351563 C 4.628906 -5.984375 4.820313 -5.53125 4.824219 -4.992188 C 4.820313 -4.714844 4.765625 -4.441406 4.652344 -4.179688 C 4.539063 -3.910156 4.351563 -3.632813 4.09375 -3.339844 C 3.832031 -3.046875 3.398438 -2.644531 2.792969 -2.132813 C 2.285156 -1.707031 1.960938 -1.417969 1.816406 -1.265625 C 1.671875 -1.113281 1.550781 -0.960938 1.460938 -0.8125 Z M 4.832031 -0.8125 "></path></symbol><symbol overflow="visible" id="glyph0-1"><path style="stroke:none;" d="M 0.871094 0 L 0.871094 -0.960938 L 1.832031 -0.960938 L 1.832031 0 Z M 0.871094 0 "></path></symbol><symbol overflow="visible" id="glyph0-2"><path style="stroke:none;" d="M 0.398438 -1.800781 L 1.285156 -1.875 C 1.347656 -1.441406 1.5 -1.117188 1.742188 -0.902344 C 1.976563 -0.683594 2.265625 -0.574219 2.605469 -0.578125 C 3.007813 -0.574219 3.351563 -0.726563 3.636719 -1.035156 C 3.914063 -1.339844 4.054688 -1.746094 4.058594 -2.253906 C 4.054688 -2.734375 3.917969 -3.113281 3.652344 -3.394531 C 3.378906 -3.667969 3.027344 -3.808594 2.59375 -3.8125 C 2.316406 -3.808594 2.070313 -3.746094 1.855469 -3.625 C 1.632813 -3.5 1.460938 -3.339844 1.339844 -3.144531 L 0.546875 -3.25 L 1.214844 -6.777344 L 4.632813 -6.777344 L 4.632813 -5.972656 L 1.890625 -5.972656 L 1.519531 -4.125 C 1.925781 -4.410156 2.359375 -4.550781 2.816406 -4.554688 C 3.414063 -4.550781 3.921875 -4.34375 4.335938 -3.929688 C 4.746094 -3.511719 4.949219 -2.976563 4.953125 -2.328125 C 4.949219 -1.703125 4.769531 -1.167969 4.410156 -0.71875 C 3.96875 -0.160156 3.367188 0.117188 2.605469 0.117188 C 1.976563 0.117188 1.464844 -0.0546875 1.074219 -0.40625 C 0.675781 -0.753906 0.453125 -1.21875 0.398438 -1.800781 Z M 0.398438 -1.800781 "></path></symbol><symbol overflow="visible" id="glyph0-3"><path style="stroke:none;" d="M 0.398438 -3.390625 C 0.398438 -4.199219 0.480469 -4.851563 0.648438 -5.351563 C 0.8125 -5.84375 1.0625 -6.226563 1.394531 -6.496094 C 1.722656 -6.761719 2.136719 -6.894531 2.640625 -6.898438 C 3.003906 -6.894531 3.328125 -6.820313 3.609375 -6.675781 C 3.886719 -6.523438 4.113281 -6.3125 4.296875 -6.035156 C 4.476563 -5.753906 4.621094 -5.410156 4.722656 -5.011719 C 4.824219 -4.605469 4.875 -4.066406 4.878906 -3.390625 C 4.875 -2.582031 4.792969 -1.929688 4.628906 -1.4375 C 4.464844 -0.9375 4.214844 -0.554688 3.886719 -0.289063 C 3.554688 -0.015625 3.140625 0.117188 2.640625 0.117188 C 1.972656 0.117188 1.453125 -0.117188 1.078125 -0.59375 C 0.625 -1.164063 0.398438 -2.097656 0.398438 -3.390625 Z M 1.265625 -3.390625 C 1.265625 -2.257813 1.394531 -1.507813 1.660156 -1.136719 C 1.921875 -0.761719 2.25 -0.574219 2.640625 -0.578125 C 3.023438 -0.574219 3.347656 -0.761719 3.613281 -1.140625 C 3.875 -1.511719 4.007813 -2.261719 4.011719 -3.390625 C 4.007813 -4.519531 3.875 -5.269531 3.613281 -5.644531 C 3.347656 -6.011719 3.019531 -6.199219 2.628906 -6.203125 C 2.238281 -6.199219 1.929688 -6.035156 1.703125 -5.710938 C 1.410156 -5.289063 1.265625 -4.515625 1.265625 -3.390625 Z M 1.265625 -3.390625 "></path></symbol><symbol overflow="visible" id="glyph0-4"><path style="stroke:none;" d="M 0.453125 -5.972656 L 0.453125 -6.78125 L 4.902344 -6.78125 L 4.902344 -6.125 C 4.460938 -5.65625 4.027344 -5.039063 3.601563 -4.269531 C 3.167969 -3.496094 2.835938 -2.703125 2.605469 -1.890625 C 2.433594 -1.3125 2.324219 -0.683594 2.28125 0 L 1.414063 0 C 1.421875 -0.539063 1.53125 -1.191406 1.734375 -1.960938 C 1.9375 -2.722656 2.226563 -3.460938 2.609375 -4.175781 C 2.984375 -4.882813 3.390625 -5.480469 3.820313 -5.972656 Z M 0.453125 -5.972656 "></path></symbol><symbol overflow="visible" id="glyph0-5"><path style="stroke:none;" d="M 3.578125 0 L 2.734375 0 L 2.734375 -5.375 C 2.527344 -5.179688 2.261719 -4.988281 1.933594 -4.792969 C 1.601563 -4.597656 1.304688 -4.453125 1.046875 -4.359375 L 1.046875 -5.175781 C 1.515625 -5.394531 1.925781 -5.664063 2.28125 -5.980469 C 2.632813 -6.292969 2.882813 -6.597656 3.03125 -6.898438 L 3.578125 -6.898438 Z M 3.578125 0 "></path></symbol><symbol overflow="visible" id="glyph1-0"><path style="stroke:none;" d="M 0.0859375 0 L 2.359375 -3.234375 L 0.257813 -6.222656 L 1.578125 -6.222656 L 2.53125 -4.765625 C 2.710938 -4.484375 2.855469 -4.253906 2.964844 -4.066406 C 3.136719 -4.324219 3.292969 -4.550781 3.4375 -4.75 L 4.488281 -6.222656 L 5.75 -6.222656 L 3.597656 -3.292969 L 5.914063 0 L 4.617188 0 L 3.339844 -1.933594 L 3 -2.453125 L 1.367188 0 Z M 0.0859375 0 "></path></symbol><symbol overflow="visible" id="glyph2-0"><path style="stroke:none;" d="M 0 -0.0859375 L -3.234375 -2.359375 L -6.222656 -0.257813 L -6.222656 -1.578125 L -4.765625 -2.53125 C -4.484375 -2.710938 -4.253906 -2.855469 -4.066406 -2.964844 C -4.324219 -3.136719 -4.550781 -3.292969 -4.75 -3.441406 L -6.222656 -4.488281 L -6.222656 -5.75 L -3.292969 -3.597656 L 0 -5.914063 L 0 -4.617188 L -1.933594 -3.339844 L -2.453125 -3 L 0 -1.367188 Z M 0 -0.0859375 "></path></symbol></g><clipPath id="clip1"> <path d="M 48.761719 14.398438 L 850.601563 14.398438 L 850.601563 540.050781 L 48.761719 540.050781 Z M 48.761719 14.398438 "></path></clipPath></defs><g id="surface1"><rect x="0" y="0" width="864" height="576" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"></rect><rect x="0" y="0" width="864" height="576" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"></rect><path style="fill:none;stroke-width:1.062992;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 0 576 L 864 576 L 864 0 L 0 0 Z M 0 576 "></path><g clip-path="url(#clip1)" clip-rule="nonzero"><path style=" stroke:none;fill-rule:nonzero;fill:rgb(89.803922%,89.803922%,89.803922%);fill-opacity:1;" d="M 48.761719 539.050781 L 849.601563 539.050781 L 849.601563 14.398438 L 48.761719 14.398438 Z M 48.761719 539.050781 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 501.957031 L 849.601563 501.957031 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 369.46875 L 849.601563 369.46875 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 236.980469 L 849.601563 236.980469 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 104.492188 L 849.601563 104.492188 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 105.386719 539.050781 L 105.386719 14.398438 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 307.617188 539.050781 L 307.617188 14.398438 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 509.851563 539.050781 L 509.851563 14.398438 "></path><path style="fill:none;stroke-width:0.531496;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(94.901961%,94.901961%,94.901961%);stroke-opacity:1;stroke-miterlimit:10;" d="M 712.082031 539.050781 L 712.082031 14.398438 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 435.710938 L 849.601563 435.710938 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 303.222656 L 849.601563 303.222656 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 170.734375 L 849.601563 170.734375 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 48.761719 38.246094 L 849.601563 38.246094 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 206.5 539.050781 L 206.5 14.398438 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 408.734375 539.050781 L 408.734375 14.398438 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 610.964844 539.050781 L 610.964844 14.398438 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:10;" d="M 813.199219 539.050781 L 813.199219 14.398438 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 87.289063 515.203125 C 87.289063 518.039063 83.035156 518.039063 83.035156 515.203125 C 83.035156 512.371094 87.289063 512.371094 87.289063 515.203125 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 168.179688 462.207031 C 168.179688 465.042969 163.929688 465.042969 163.929688 462.207031 C 163.929688 459.375 168.179688 459.375 168.179688 462.207031 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 249.074219 409.214844 C 249.074219 412.046875 244.824219 412.046875 244.824219 409.214844 C 244.824219 406.378906 249.074219 406.378906 249.074219 409.214844 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 329.96875 356.21875 C 329.96875 359.054688 325.714844 359.054688 325.714844 356.21875 C 325.714844 353.382813 329.96875 353.382813 329.96875 356.21875 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 410.859375 303.222656 C 410.859375 306.058594 406.609375 306.058594 406.609375 303.222656 C 406.609375 300.390625 410.859375 300.390625 410.859375 303.222656 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 491.753906 250.226563 C 491.753906 253.0625 487.5 253.0625 487.5 250.226563 C 487.5 247.394531 491.753906 247.394531 491.753906 250.226563 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 572.644531 197.234375 C 572.644531 200.066406 568.394531 200.066406 568.394531 197.234375 C 568.394531 194.398438 572.644531 194.398438 572.644531 197.234375 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 653.539063 144.238281 C 653.539063 147.074219 649.285156 147.074219 649.285156 144.238281 C 649.285156 141.402344 653.539063 141.402344 653.539063 144.238281 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 734.429688 91.242188 C 734.429688 94.078125 730.179688 94.078125 730.179688 91.242188 C 730.179688 88.410156 734.429688 88.410156 734.429688 91.242188 "></path><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 815.324219 38.246094 C 815.324219 41.082031 811.070313 41.082031 811.070313 38.246094 C 811.070313 35.414063 815.324219 35.414063 815.324219 38.246094 "></path></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-0" x="28.332031" y="439.148438"></use> <use xlink:href="#glyph0-1" x="33.671094" y="439.148438"></use> <use xlink:href="#glyph0-2" x="36.338281" y="439.148438"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-2" x="28.332031" y="306.660156"></use> <use xlink:href="#glyph0-1" x="33.671094" y="306.660156"></use> <use xlink:href="#glyph0-3" x="36.338281" y="306.660156"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-4" x="28.332031" y="174.171875"></use> <use xlink:href="#glyph0-1" x="33.671094" y="174.171875"></use> <use xlink:href="#glyph0-2" x="36.338281" y="174.171875"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-5" x="22.992188" y="41.683594"></use> <use xlink:href="#glyph0-3" x="28.33125" y="41.683594"></use> <use xlink:href="#glyph0-1" x="33.670313" y="41.683594"></use> <use xlink:href="#glyph0-3" x="36.3375" y="41.683594"></use></g><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 44.507813 435.710938 L 48.761719 435.710938 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 44.507813 303.222656 L 48.761719 303.222656 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 44.507813 170.734375 L 48.761719 170.734375 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 44.507813 38.246094 L 48.761719 38.246094 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 206.5 543.304688 L 206.5 539.050781 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 408.734375 543.304688 L 408.734375 539.050781 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 610.964844 543.304688 L 610.964844 539.050781 "></path><path style="fill:none;stroke-width:1.062992;stroke-linecap:butt;stroke-linejoin:round;stroke:rgb(49.803922%,49.803922%,49.803922%);stroke-opacity:1;stroke-miterlimit:10;" d="M 813.199219 543.304688 L 813.199219 539.050781 "></path><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-0" x="199.828125" y="553.011719"></use> <use xlink:href="#glyph0-1" x="205.167188" y="553.011719"></use> <use xlink:href="#glyph0-2" x="207.834375" y="553.011719"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-2" x="402.0625" y="553.011719"></use> <use xlink:href="#glyph0-1" x="407.401563" y="553.011719"></use> <use xlink:href="#glyph0-3" x="410.06875" y="553.011719"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-4" x="604.292969" y="553.011719"></use> <use xlink:href="#glyph0-1" x="609.632031" y="553.011719"></use> <use xlink:href="#glyph0-2" x="612.299219" y="553.011719"></use></g><g style="fill:rgb(49.803922%,49.803922%,49.803922%);fill-opacity:1;"> <use xlink:href="#glyph0-5" x="803.855469" y="553.011719"></use> <use xlink:href="#glyph0-3" x="809.194531" y="553.011719"></use> <use xlink:href="#glyph0-1" x="814.533594" y="553.011719"></use> <use xlink:href="#glyph0-3" x="817.200781" y="553.011719"></use></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph1-0" x="446.179688" y="565.199219"></use></g><g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph2-0" x="19.390625" y="279.726563"></use></g></g></svg>
I'm very aware of gridSVG
. Its output is nice and predictable, but it is slow.
I think that's mostly coincidence. A simpler example doesn't seem terribly well structured:
svg()
plot(1:3, axes = F, xlab = "", ylab = "")
points(3:1, col = "red")
dev.off()
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="504pt" height="504pt" viewBox="0 0 504 504" version="1.1">
<g id="surface16">
<rect x="0" y="0" width="504" height="504" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 77.101562 416.800781 C 77.101562 420.398438 71.699219 420.398438 71.699219 416.800781 C 71.699219 413.199219 77.101562 413.199219 77.101562 416.800781 "/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 269.101562 244.800781 C 269.101562 248.398438 263.699219 248.398438 263.699219 244.800781 C 263.699219 241.199219 269.101562 241.199219 269.101562 244.800781 "/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 461.101562 72.800781 C 461.101562 76.398438 455.699219 76.398438 455.699219 72.800781 C 455.699219 69.199219 461.101562 69.199219 461.101562 72.800781 "/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(100%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 77.101562 72.800781 C 77.101562 76.398438 71.699219 76.398438 71.699219 72.800781 C 71.699219 69.199219 77.101562 69.199219 77.101562 72.800781 "/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(100%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 269.101562 244.800781 C 269.101562 248.398438 263.699219 248.398438 263.699219 244.800781 C 263.699219 241.199219 269.101562 241.199219 269.101562 244.800781 "/>
<path style="fill:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(100%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 461.101562 416.800781 C 461.101562 420.398438 455.699219 420.398438 455.699219 416.800781 C 455.699219 413.199219 461.101562 413.199219 461.101562 416.800781 "/>
</g>
</svg>
I can assure you that you want is not possible based on the underlying R graphics device API.
@hadley Yes, I am ok with that. About rvg known issues:
@timelyportfolio this is produced by Cairo. I don't know how and why but many of the
@davidgohel yeah, I wasn't sure what you were doing there. I think we can just set the global doc encoding to utf-8, and then output characters as is. Also could you describe your general approach to clipping? Why not use the native svg stuff?
Hum... The reason is... I have written the DrawingML devices (in ReporteRs) first and I just realized it was much simpler in SVG (DML does not support clipping).
@hadley in the absence of any other identifying information, at least with old svg
we can separate the plotting surface (data) with the axes and other components. Although not important for export to Illustrator/Inkscape/Word, this becomes important if we want to match/bind data to their corresponding marks/geoms/points. Maybe, I should just stick with gridSVG
.
@timelyportfolio unfortunately that's just not possible in general. I'd recommend making gridSVG faster.
Well, you say not possible, but svg
provides at least a clue with the second level g
with clippath when axes are drawn. How does it accomplish this when infrastructure/parts seem about the same?
It's probably something to do with the precise order in which things are plotted, which is frail. I have read the source code for the R graphics device API - what you want IS NOT POSSIBLE.
@hadley, thanks so much for the clarification.
Hi,
I've just added @hadley as collaborator to the RSVGDevice project and merged his work. As I said, I just fixed some things of the original RSVGDevice developped by @tjake and I didn't know the rvg package until yesterday.
I use this package mainly because :
+1
Not sure if @mdecorde is active on github yet, but it would seem natural to combine efforts.