Sha256: 5b34e3341b1fd4c2e1f4589fea4c7047ad028270469d898e9ffb7c093d836113

Contents?: true

Size: 1.32 KB

Versions: 214

Compression:

Stored size: 1.32 KB

Contents

library(plyr)
library(proto)
library(ggplot2)
library(gridSVG)
library(grid)
library(XML)
library(ggthemes)
library(Cairo)

# Modified from http://aaronecay.com/blog/2014/02/tooltips-in-ggplot/

rbbt.SVG.extract <- function(plot, size=NULL, prefix=NULL, ...){

    if (is.null(prefix)) prefix = rbbt.random_string();
    if (is.null(size)){
        print(plot, type='cairo');
        mysvg <- grid.export(prefix=prefix, ...)
    }else{
        base.size = 10 * (7/size)
        resolution = 72 * (size/7)

        if (length(plot$theme) == 0) plot <- plot + theme_gdocs();

        plot$theme$text$size = base.size

        print(plot, type='cairo')

        mysvg <- grid.export(res=resolution, prefix=prefix, ...)
    }

    xml <- saveXML(mysvg$svg)
    xml
}

rbbt.SVG.save <- function(filename, plot, width=NULL, height=NULL){
    if (is.null(width)){
        if (is.null(height)){
            size = NULL
        }else{
            size=height
        }
    }else{
        if (is.null(height)){
            size = width
        }else{
            size=max(width, height)
        }
    }

    xml = rbbt.SVG.extract(plot, size)
    fileConn<-file(filename, 'w')
    cat(xml, file=fileConn)
    close(fileConn)
}

rbbt.SVG.save.fast <- function(filename, plot, width=3, height=3){
    ggsave(file=filename, plot, width=width, height=height);
}

Version data entries

214 entries across 214 versions & 1 rubygems

Version Path
rbbt-util-5.21.96 share/Rlib/svg.R
rbbt-util-5.21.95 share/Rlib/svg.R
rbbt-util-5.21.94 share/Rlib/svg.R
rbbt-util-5.21.93 share/Rlib/svg.R
rbbt-util-5.21.92 share/Rlib/svg.R
rbbt-util-5.21.91 share/Rlib/svg.R
rbbt-util-5.21.90 share/Rlib/svg.R
rbbt-util-5.21.89 share/Rlib/svg.R
rbbt-util-5.21.87 share/Rlib/svg.R
rbbt-util-5.21.86 share/Rlib/svg.R
rbbt-util-5.21.85 share/Rlib/svg.R
rbbt-util-5.21.84 share/Rlib/svg.R
rbbt-util-5.21.83 share/Rlib/svg.R
rbbt-util-5.21.81 share/Rlib/svg.R
rbbt-util-5.21.80 share/Rlib/svg.R
rbbt-util-5.21.78 share/Rlib/svg.R
rbbt-util-5.21.77 share/Rlib/svg.R
rbbt-util-5.21.76 share/Rlib/svg.R
rbbt-util-5.21.75 share/Rlib/svg.R
rbbt-util-5.21.74 share/Rlib/svg.R