plot_HK_SAR_flag: Draw the Regional Flag of the Hong Kong Special...

View source: R/plot_region_flag.R

plot_HK_SAR_flagR Documentation

Draw the Regional Flag of the Hong Kong Special Administrative Region

Description

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.

Usage

plot_HK_SAR_flag(label = TRUE)

Arguments

label

Logical scalar. If TRUE (the default), the plot is annotated with a title and axis captions identifying the standard and drawing reference. If FALSE, all text annotations are suppressed, yielding a bare flag suitable for embedding or export.

Details

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.

Value

A ggplot object. The object can be printed, further modified with additional ggplot2 layers, or written to disk with ggsave.

Rendering notes

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.

References

GB 16689-2004. Regional flag of the Hong Kong Special Administrative Region of the People's Republic of China. Standardization Administration of China.

See Also

ggplot, ggsave

Examples


# 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)




ggChinaFlag documentation built on Oct. 1, 2026, 5:11 p.m.