ggplot_translator: Translate axis label of a ggplot

View source: R/plots.R

ggplot_translatorR Documentation

Translate axis label of a ggplot

Description

Translate axis label of a ggplot

Usage

ggplot_translator(
  gg,
  which = c("x", "y"),
  from = "en",
  to = "zh",
  keep_original_label = FALSE,
  original_sep = "\n",
  verbose = TRUE
)

Arguments

gg

a ggplot object to be translated

which

vector contains one or more of 'x', 'y', 'label', 'fill', 'color'..., or 'facet_x', 'facet_y', 'labs' and 'all' to select which texts to be translated.

from

source language

to

target language

keep_original_label

keep the source language labels

original_sep

default, '\n'

verbose

verbose

Value

ggplot

Examples

## Not run: 
df <- data.frame(
  Subject = c("English", "Math"),
  Score = c(59, 98), Motion = c("sad", "happy")
)
ggp <- ggplot(df, mapping = aes(x = Subject, y = Score, label = Motion)) +
  geom_text() +
  geom_point() +
  labs(x = "Subject", y = "Score", title = "Final Examination")
ggplot_translator(ggp, which = "all")

## End(Not run)

pcutils documentation built on June 26, 2024, 1:06 a.m.