print.unicode_ggplot: Print a unicode_ggplot object with automatic showtext support

View source: R/plot.R

print.unicode_ggplotR Documentation

Print a unicode_ggplot object with automatic showtext support

Description

This method temporarily activates the showtext graphics engine to ensure that Unicode characters (e.g., Chinese, special symbols) are rendered correctly when the plot is displayed. After printing, the original graphics device state is restored.

Usage

## S3 method for class 'unicode_ggplot'
print(x, ...)

Arguments

x

A unicode_ggplot object (a ggplot with an extra class).

...

Additional arguments passed to the next print method (e.g., to print.ggplot).

Details

The method calls showtext::showtext_begin(), then uses NextMethod() to invoke the original print.ggplot method, which actually draws the plot. Finally, showtext::showtext_end() is called to restore the device. This all happens automatically when a unicode_ggplot object is printed (e.g., when its name is typed at the console or when print() is explicitly called).

Value

The input object x, returned invisibly.

See Also

scatter_plot for creating such objects, ggsave_unicode for saving them with Unicode support.

Examples

## Not run: 
p <- scatter_plot(...)   # returns a unicode_ggplot object
p                             # automatically uses this print method

## End(Not run)


ncmR documentation built on April 19, 2026, 5:07 p.m.