knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

add2ggplot

CRAN status DOI

The goal of add2ggplot is to add more theme for your ggplot object.

Installation

You can install the released version of add2ggplot from CRAN with:

install.packages("add2ggplot")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("JiaxiangBU/add2ggplot")

Examples

library(add2ggplot)
plot_logo <- add_logo(
  plot_path = "inst/extdata/logo.png",
  logo_path = "inst/extdata/jiaxiang.png",
  logo_position = "bottom right",
  logo_scale = 5)
plot_logo
library(ggrepel)
df <- 
mtcars %>%
    tibble::rownames_to_column()
df %>%
    ggplot() +
    aes(mpg, disp, label = rowname) +
    geom_point(color = 'white') +
    # geom_label_repel use fill arg in the segments.
    geom_label_repel(
        data = function(x)
            df %>% head,
        arrow = arrow(length = unit(0.02, "npc")),
        box.padding = 1,
        segment.color = white_one,
        color = white_one,
        label.size = NA,
        fill = red_two,
        aes(face = "bold")
    ) +
    # theme_white()
    theme_grey_and_red() +
    labs(
        title = '浣跨敤labs瑕嗙洊',
        subtitle = '浣跨敤labs瑕嗙洊',
        x = '浣跨敤labs瑕嗙洊',
        y = '浣跨敤labs瑕嗙洊',
        caption = '澶囨敞: 浣跨敤labs瑕嗙洊'
    )
z <-
    ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, col = Species)) +
    geom_jitter(alpha = 0.7) +
    scale_color_brewer(
        "Species",
        palette = "Dark2",
        labels = c("Setosa",
                   "Versicolor",
                   "Virginica")
    ) +
    scale_y_continuous("Width (cm)",
                       limits = c(2, 4.5),
                       expand = c(0, 0)) +
    scale_x_continuous("Length (cm)", limits = c(4, 8), expand = c(0, 0)) +
    ggtitle("Sepals") +
    coord_fixed(1)
z
z + theme_classic()
z + theme_classic2()

Citations

citations <- add2pkg::add_zenodo_citation("README.Rmd")
cat(citations$Cite)
cat(paste0("```BibTex\n",citations$BibTex,"\n```"))
cat(citations$Comments)

r add2pkg::add_disclaimer("Jiaxiang Li;Nakagawara Ryo")



JiaxiangBU/add2ggplot documentation built on Feb. 10, 2020, 10:41 a.m.