View source: R/plot_region_flag.R
| plot_HK_SAR_flag | R Documentation |
Constructs the flag of the Hong Kong Special Administrative Region of the People's Republic of China entirely from analytic geometry and renders it as a ggplot2 object. The five-petal bauhinia emblem is built by deriving every construction point (circle intersections, line intersections, and rotation angles) from the specification, then replicating a single petal five times at 72-degree increments about the emblem centre.
plot_HK_SAR_flag(label = TRUE)
label |
Logical scalar. If |
The geometry follows the Chinese national standard GB 16689-2004. A single
petal is bounded by seven edge segments: six circular arcs drawn on four
distinct construction circles, plus one straight chord. Each arc is sampled
into a dense polyline (400 points by default) so that
geom_polygon can fill the enclosed region; at this
sampling density the chordal deviation from the true arc is several orders of
magnitude below any practical display or print resolution.
The flag field is a red rectangle with a 3:2 width-to-height ratio, sized relative to the emblem's bounding circle radius. Petals are white and each carries a red five-pointed star.
All construction is performed in a local coordinate system with the emblem's outer circle centred at the origin with radius 60. The function is self-contained: it defines its own geometric helpers internally and depends only on ggplot2 for rendering and showtext for CJK glyph support.
A ggplot object. The object can be printed, further modified
with additional ggplot2 layers, or written to disk with
ggsave.
Correct display of the Chinese title and caption requires a font providing
CJK glyphs. The function calls showtext_auto, but the
user must register a suitable font beforehand, for example via
font_add or font_add_google.
Without a registered CJK font the non-ASCII labels may render as blank boxes.
The plot uses coord_fixed to enforce a 1:1 aspect
ratio; altering the coordinate system will distort the circular arcs.
GB 16689-2004. Regional flag of the Hong Kong Special Administrative Region of the People's Republic of China. Standardization Administration of China.
ggplot, ggsave
# Register a CJK font before plotting annotated output
if (requireNamespace("sysfonts", quietly = TRUE)) {
sysfonts::font_add_google("Noto Sans SC", "notosans")
showtext::showtext_auto()
}
# Annotated flag
plot_HK_SAR_flag()
# Bare flag, no text
plot_HK_SAR_flag(label = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.