| 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 |
| 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 |
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 |
label |
Logical; whether to display the title and text annotations.
Default is |
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 |
label |
Logical value indicating whether to display textual annotations
(title and axis labels). Default is |
Details
Two rendering modes are supported:
-
"flag": A rectangular background with a 3:2 aspect ratio, suitable for flag-style visualization. -
"logo": A square (1:1) background, suitable for emblem or logo-style visualization.
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.
|
Details
The aspect ratio is 5:8; x ranges over [-80, 80], y over [-50, 50].
The nine-pointed star has a circumscribed radius of 44 units and an inner radius of 8 units.
Nine outer yellow dots sit along the star tips; nine inner dots sit midway between the centre and the tips.
-
ggplot2::coord_fixed(ratio = 1)keeps the proportions fixed. Axes, grid and legend are hidden by default.
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 |
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
|
Details
The flag has a 3:2 aspect ratio.
The large star is placed in the upper-left canton.
The four small stars are positioned per the specification and rotated to point at the large star.
-
ggplot2::coord_quickmap()keeps a 1:1 x:y ratio.
Value
A ggplot object, which can be printed directly or saved with
ggsave().
Author(s)
Flag design: Zeng Liansong.
See Also
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.
|
Details
The flag is built from five equal-height horizontal rectangles.
From top to bottom the colours are red, yellow, blue, white, black.
These represent the Han, Manchu, Mongol, Hui and Tibetan peoples.
-
ggplot2::coord_quickmap()keeps the proportions undistorted. Axes, grid and legend are hidden.
Value
A ggplot object, which can be printed or saved with
ggsave().
Author(s)
Historical flag of the Beiyang Government era.
See Also
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.
|
Details
The red field and blue canton are built from rectangles.
The twelve-rayed sun is a closed polygon of 24 vertices.
Two concentric circles form the core of the white sun.
-
ggplot2::coord_quickmap()keeps the proportions undistorted. Axes, grid and legend are hidden by default.
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)