Sha256: 35939d4c76ab02758b09adcabaad8285d27acd21d3ab6cf5e21b0613f3259a70

Contents?: true

Size: 1.71 KB

Versions: 43

Compression:

Stored size: 1.71 KB

Contents

rbbt.require('ggplot2')

geom_entity <- function (real.geom = NULL, mapping = NULL, data = NULL, stat = "identity",
                          position = "identity", ...) {
    rg <- real.geom(mapping = mapping, data = data, stat = stat, 
                    position = position, ...)

    rg$geom <- proto(rg$geom, { 
        draw <- function(., data, ...) {
            grobs <- list()

            for (i in 1:nrow(data)) {
                grob <- .super$draw(., data[i,], ...) 
                if (is.null(data$entity.type)) 
                    grobs[[i]] <- garnishGrob(grob, `data-entity`=data[i,]$entity)
                else
                    grobs[[i]] <- garnishGrob(grob, `data-entity`=data[i,]$entity, `data-entity-type`=data[i,]$entity.type)
            }

            ggplot2:::ggname("geom_entity", gTree(children = do.call("gList", grobs)))
        }

        draw_groups <- function(., data, ...) {
            grobs <- list()

            for (i in 1:nrow(data)) {
                grob <- .super$draw_groups(., data[i,], ...) 
                if (is.null(data$entity.type)) 
                    grobs[[i]] <- garnishGrob(grob, `data-entity`=data[i,]$entity)
                else
                    grobs[[i]] <- garnishGrob(grob, `data-entity`=data[i,]$entity, `data-entity-type`=data[i,]$entity.type)
            }

            ggplot2:::ggname("geom_entity", gTree(children = do.call("gList", grobs)))
        }
    })

    rg
}

rbbt.ggplot2.rotate_x_labels <- function(){ theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) }

rbbt.ggplot2.theme <- function(plot){

    plot + theme_classic() + scale_y_continuous(labels=scales::comma) + scale_x_continuous(labels=scales::comma) + rbbt.ggplot2.rotate_x_labels()

}

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rbbt-util-5.43.0 share/Rlib/plot.R
rbbt-util-5.42.0 share/Rlib/plot.R
rbbt-util-5.41.1 share/Rlib/plot.R
rbbt-util-5.41.0 share/Rlib/plot.R
rbbt-util-5.40.5 share/Rlib/plot.R
rbbt-util-5.40.4 share/Rlib/plot.R
rbbt-util-5.40.3 share/Rlib/plot.R
rbbt-util-5.40.0 share/Rlib/plot.R
rbbt-util-5.39.0 share/Rlib/plot.R
rbbt-util-5.38.1 share/Rlib/plot.R
rbbt-util-5.38.0 share/Rlib/plot.R
rbbt-util-5.37.16 share/Rlib/plot.R
rbbt-util-5.37.15 share/Rlib/plot.R
rbbt-util-5.37.14 share/Rlib/plot.R
rbbt-util-5.37.13 share/Rlib/plot.R
rbbt-util-5.37.12 share/Rlib/plot.R
rbbt-util-5.37.11 share/Rlib/plot.R
rbbt-util-5.37.10 share/Rlib/plot.R
rbbt-util-5.37.9 share/Rlib/plot.R
rbbt-util-5.37.8 share/Rlib/plot.R