| Title: | Drawing Chinese National and Historical Flags with 'ggplot2' |
|---|---|
| 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. |
| Authors: | Zhaoshuo Liu [aut, cre] (ORCID: <https://orcid.org/0009-0007-3615-5724>) |
| Maintainer: | Zhaoshuo Liu <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.0 |
| Built: | 2026-07-05 08:19:35 UTC |
| Source: | https://github.com/xlions/ggchinaflag |
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.
FlagStorage(lang = c("Chinese", "English"))FlagStorage(lang = c("Chinese", "English"))
lang |
Character string giving the language of the returned names.
Either |
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.
plotCNFlag, which matches against these names.
# Chinese names FlagStorage() # English names FlagStorage(lang = "English")# Chinese names FlagStorage() # English names FlagStorage(lang = "English")
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.
plot_CCP(plot_type = "flag", label = FALSE)plot_CCP(plot_type = "flag", label = FALSE)
plot_type |
Character string specifying the rendering mode.
Either |
label |
Logical value indicating whether to display textual annotations
(title and axis labels). Default is |
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.
A ggplot object representing the CCP emblem or flag.
Per the regulations on the emblem and flag of the Communist Party of China.
plotCNFlag for the unified flag plotting interface.
plot_CCP(plot_type = "flag") plot_CCP(plot_type = "logo")plot_CCP(plot_type = "flag") plot_CCP(plot_type = "logo")
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.
plot_Han18Star(label = TRUE)plot_Han18Star(label = TRUE)
label |
Logical; whether to display the title and explanatory text.
|
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.
A ggplot object, which can be printed or saved with
ggsave().
Flag design: the Chinese Revolutionary Alliance (Tongmenghui).
https://www.19111010.com.tw/story?id=93
geom_polygon,
geom_circle,
plot_P.R.CHINA_flag,
plot_ROC_Beiyang_flag,
plot_ROC_KMT_flag
plot_Han18Star() plot_Han18Star(label = FALSE)plot_Han18Star() plot_Han18Star(label = FALSE)
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.
plot_KMT(label = TRUE)plot_KMT(label = TRUE)
label |
Logical value indicating whether to display textual annotations
(title and axis labels). Default is |
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.
A ggplot object representing the Blue Sky with a White Sun flag.
Design: Lu Haodong.
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
plotCNFlag for the unified flag plotting interface.
plot_KMT() plot_KMT(label = FALSE)plot_KMT() plot_KMT(label = FALSE)
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.
plot_P.R.CHINA_flag(label = TRUE)plot_P.R.CHINA_flag(label = TRUE)
label |
Logical; whether to display the title and axis text. If
|
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.
A ggplot object, which can be printed directly or saved with
ggsave().
Flag design: Zeng Liansong.
plot_P.R.CHINA_flag() plot_P.R.CHINA_flag(label = FALSE)plot_P.R.CHINA_flag() plot_P.R.CHINA_flag(label = FALSE)
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.
plot_ROC_Beiyang_flag(label = TRUE)plot_ROC_Beiyang_flag(label = TRUE)
label |
Logical; whether to display the title and explanatory text.
|
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.
A ggplot object, which can be printed or saved with
ggsave().
Historical flag of the Beiyang Government era.
plot_ROC_Beiyang_flag() plot_ROC_Beiyang_flag(label = FALSE)plot_ROC_Beiyang_flag() plot_ROC_Beiyang_flag(label = FALSE)
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.
plot_ROC_KMT_flag(label = TRUE)plot_ROC_KMT_flag(label = TRUE)
label |
Logical; whether to display the title and explanatory text.
|
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.
A ggplot object, which can be printed or saved with
ggsave().
Design: Sun Yat-sen (proposal) and Lu Haodong (Blue Sky, White Sun).
geom_polygon,
geom_rect,
geom_circle
plot_ROC_KMT_flag() plot_ROC_KMT_flag(label = FALSE)plot_ROC_KMT_flag() plot_ROC_KMT_flag(label = FALSE)
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.
plotCNFlag(input, label = TRUE)plotCNFlag(input, label = TRUE)
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 |
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.
A ggplot object, which can be printed directly or saved with
ggsave().
FlagStorage for the name list, and the underlying
plotting functions such as plot_P.R.CHINA_flag.
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")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")