Package {ggChinaFlag}


Type: Package
Title: Drawing Chinese National and Historical Flags with 'ggplot2'
Version: 0.2.0
Description: Provides programmatic implementations for drawing Chinese national and historical flags using analytic geometry and 'ggplot2'-based vector graphics. Flag designs are constructed entirely from geometric primitives such as polygons and rectangles, without relying on external image files. The package is intended for educational demonstration, reproducible visualization, and procedural graphics in R.
License: GPL-3
Encoding: UTF-8
Imports: ggplot2, dplyr, showtext, ggforce
RoxygenNote: 7.3.3
URL: https://github.com/XLions/ggChinaFlag
BugReports: https://github.com/XLions/ggChinaFlag/issues
NeedsCompilation: no
Packaged: 2026-06-28 13:25:23 UTC; lzs19
Author: Zhaoshuo Liu ORCID iD [aut, cre]
Maintainer: Zhaoshuo Liu <liuzhaoshuo1997@outlook.com>
Repository: CRAN
Date/Publication: 2026-07-04 07:10:28 UTC

Built-in Chinese and English names of the flags

Description

Provides a standardised list of flag names used by plotCNFlag and related functions. It contains the names of the national flag of the People's Republic of China, several historical flags of the Republic of China, and the party flags of the Communist Party of China and the Kuomintang, in both Chinese and English.

Usage

FlagStorage(lang = c("Chinese", "English"))

Arguments

lang

Character string giving the language of the returned names. Either "Chinese" (default) or "English".

Value

A list of two named character vectors. With lang = "Chinese" the elements hold the Chinese national-flag and political-party names; with lang = "English" they are named National Flags and Political Parties. The strings in each vector correspond one-to-one to the underlying plotting functions.

See Also

plotCNFlag, which matches against these names.

Examples

# Chinese names
FlagStorage()

# English names
FlagStorage(lang = "English")


Plot a Chinese national or historical flag by name

Description

A unified interface that dispatches to the appropriate low-level plotting function based on the supplied flag name (Chinese or English) and returns a ggplot object.

Usage

plotCNFlag(input, label = TRUE)

Arguments

input

Character string giving the flag to plot, either a Chinese or an English name; see FlagStorage for the supported names.

label

Logical; whether to display the title and text annotations. Default is TRUE.

Details

The function obtains the built-in name list via FlagStorage, detects the input language, matches the name, and forwards to one of plot_P.R.CHINA_flag, plot_ROC_KMT_flag, plot_ROC_Beiyang_flag, plot_Han18Star, plot_CCP or plot_KMT. An unrecognised name raises an error.

Value

A ggplot object, which can be printed directly or saved with ggsave().

See Also

FlagStorage for the name list, and the underlying plotting functions such as plot_P.R.CHINA_flag.

Examples


plotCNFlag("Flag of the People's Republic of China")
plotCNFlag("Flag of the Kuomintang (Blue Sky and White Sun flag)", label = FALSE)
plotCNFlag("Five-Color Flag of the Beiyang Government of the Republic of China")
plotCNFlag("Iron-Blood 18-Star Flag of the Wuchang Uprising")



Plot the emblem or flag of the Communist Party of China (CCP)

Description

This function programmatically renders the emblem of the Communist Party of China using analytic geometry and ggplot2-based vector graphics. The symbol is constructed entirely from geometric primitives (arcs, polygons, and rectangles), without relying on any external image files.

Usage

plot_CCP(plot_type = "flag", label = FALSE)

Arguments

plot_type

Character string specifying the rendering mode. Either "flag" (default) or "logo".

label

Logical value indicating whether to display textual annotations (title and axis labels). Default is FALSE.

Details

Two rendering modes are supported:

The geometric construction follows a stepwise layering strategy, including the outer and inner arcs of the sickle, the handle, and the hammer body. All coordinates are transformed into a unified plotting coordinate system.

Value

A ggplot object representing the CCP emblem or flag.

Author(s)

Per the regulations on the emblem and flag of the Communist Party of China.

See Also

plotCNFlag for the unified flag plotting interface.

Examples


plot_CCP(plot_type = "flag")
plot_CCP(plot_type = "logo")



Plot the Iron-Blood 18-Star Flag of the Wuchang Uprising

Description

Draws the Iron-Blood 18-Star Flag (also called the Nine-Pointed Eighteen-Star Flag) used by the Hubei military government after the Wuchang Uprising of the Xinhai Revolution. The flag has a red field, a central black nine-pointed star, and nine inner and nine outer yellow dots representing the eighteen Han provinces of the time. All shapes are generated by vector computation, without external image files.

Usage

plot_Han18Star(label = TRUE)

Arguments

label

Logical; whether to display the title and explanatory text. TRUE (default) shows the title, designer and historical background; FALSE draws only the flag.

Details

Value

A ggplot object, which can be printed or saved with ggsave().

Author(s)

Flag design: the Chinese Revolutionary Alliance (Tongmenghui).

References

https://www.19111010.com.tw/story?id=93

See Also

geom_polygon, geom_circle, plot_P.R.CHINA_flag, plot_ROC_Beiyang_flag, plot_ROC_KMT_flag

Examples


plot_Han18Star()
plot_Han18Star(label = FALSE)



Plot the Blue Sky with a White Sun flag (Kuomintang / Republic of China)

Description

This function programmatically renders the Blue Sky with a White Sun symbol using analytic geometry and ggplot2-based vector graphics. The emblem consists of a blue background and a twelve-rayed white sun, constructed entirely from geometric primitives such as polygons, circles, and arcs, without relying on any external image files.

Usage

plot_KMT(label = TRUE)

Arguments

label

Logical value indicating whether to display textual annotations (title and axis labels). Default is TRUE.

Details

The geometric construction follows the official construction sheets and historical specifications of the flag, ensuring proportional accuracy of the twelve rays and concentric circles.

The twelve-rayed sun is constructed by alternating outer and inner vertices arranged in clockwise order, forming a closed polygon. Two concentric circles are then overlaid to form the central white sun core.

Value

A ggplot object representing the Blue Sky with a White Sun flag.

Author(s)

Design: Lu Haodong.

References

Wikipedia contributors. Flag of the Republic of China. https://en.wikipedia.org/wiki/Flag_of_the_Republic_of_China

Wikimedia Commons. https://commons.wikimedia.org/wiki/File:Flag_of_the_Republic_of_China_construction_sheet.svg

See Also

plotCNFlag for the unified flag plotting interface.

Examples


plot_KMT()
plot_KMT(label = FALSE)



Plot the national flag of the People's Republic of China

Description

Draws the national flag of the People's Republic of China at the regulation proportions using pure geometric computation and ggplot2. The shape and orientation of the stars are computed analytically so that each small star points to the centre of the large star. No external image or SVG resources are used, which makes the function suitable for teaching and programmatic graphics.

Usage

plot_P.R.CHINA_flag(label = TRUE)

Arguments

label

Logical; whether to display the title and axis text. If TRUE (default) the title, designer and reference information are shown; if FALSE only the flag is drawn.

Details

Value

A ggplot object, which can be printed directly or saved with ggsave().

Author(s)

Flag design: Zeng Liansong.

See Also

geom_polygon, coord_quickmap

Examples


plot_P.R.CHINA_flag()
plot_P.R.CHINA_flag(label = FALSE)



Plot the Five-Colored Flag of the Beiyang Government

Description

Draws the Five-Colored Flag used during the Beiyang Government period (circa 1912-1928) of the Republic of China, using horizontal colour bands rendered with ggplot2. The flag has five equal horizontal stripes in red, yellow, blue, white and black, symbolising the Han, Manchu, Mongol, Hui and Tibetan peoples. The drawing is fully programmatic and uses no external image resources.

Usage

plot_ROC_Beiyang_flag(label = TRUE)

Arguments

label

Logical; whether to display the title and explanatory text. TRUE (default) shows the title and annotations; FALSE draws only the flag.

Details

Value

A ggplot object, which can be printed or saved with ggsave().

Author(s)

Historical flag of the Beiyang Government era.

See Also

geom_rect, coord_quickmap

Examples


plot_ROC_Beiyang_flag()
plot_ROC_Beiyang_flag(label = FALSE)



Plot the Blue Sky, White Sun, and a Wholly Red Earth flag

Description

Programmatically draws the Blue Sky, White Sun, and a Wholly Red Earth flag used during the Nationalist Government period (1928-1949) of the Republic of China, using analytic geometry with ggplot2 and ggforce. The flag has a red field, a blue canton in the upper-left, and a twelve-rayed white sun within the canton, all generated from vector geometry without external image files.

Usage

plot_ROC_KMT_flag(label = TRUE)

Arguments

label

Logical; whether to display the title and explanatory text. TRUE (default) shows the title, designer and period; FALSE draws only the flag.

Details

Value

A ggplot object, which can be printed or saved with ggsave().

Author(s)

Design: Sun Yat-sen (proposal) and Lu Haodong (Blue Sky, White Sun).

See Also

geom_polygon, geom_rect, geom_circle

Examples


plot_ROC_KMT_flag()
plot_ROC_KMT_flag(label = FALSE)


mirror server hosted at Truenetwork, Russian Federation.