The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: A 'ggplot2' Extension for Translating Plot Text
Version: 0.1.0
Maintainer: Mathias Leroy <mathias.leroy.rpkg@gmail.com>
Description: Provides a simple way to translate text elements in 'ggplot2' plots using a dictionary-based approach.
Encoding: UTF-8
RoxygenNote: 7.3.1
URL: https://github.com/mathiasleroy/ggtranslate
BugReports: https://github.com/mathiasleroy/ggtranslate/issues
Imports: ggplot2, rlang
Suggests: testthat (≥ 3.0.0)
License: MIT + file LICENSE
NeedsCompilation: no
Packaged: 2025-07-07 11:40:16 UTC; mleroy
Author: Mathias Leroy [aut, cre]
Repository: CRAN
Date/Publication: 2025-07-10 15:00:02 UTC

Translate all text elements in a ggplot2 object

Description

This function takes a ggplot2 object and a named list to translate all user-facing text elements within the plot. This includes main plot labels (title, subtitle, captions, axis titles, legend titles), discrete axis tick labels, discrete legend keys, facet labels, and text from 'geom_text'/'geom_label'.

Usage

ggtranslate(plot, dictionary_list)

Arguments

plot

A ggplot object whose text elements are to be translated.

dictionary_list

A named list where the names are the original text and the values are the translated text.

Value

A modified ggplot object with all translatable text elements replaced according to the provided dictionary list.

Examples

library(ggplot2)

df <- data.frame(
  day = factor(c("Monday", "Tuesday"), levels = c("Monday", "Tuesday")),
  value = c(10, 12)
)
translation_fr <- list(
  "Monday" = "Lundi",
  "Tuesday" = "Mardi",
  "Weekly Report" = "Rapport Hebdomadaire"
)
p_en <- ggplot(df, aes(x = day, y = value)) +
  geom_col() +
  labs(title = "Weekly Report")
p_fr <- ggtranslate(p_en, translation_fr)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.