Plot kanjivec objects
Arguments
- x
an object of class
kanjivec
- type
either "kanji" or "dend". Whether to plot the actual kanji, coloring strokes according to levels of segmentation, or to plot a representation of the tree structure underlying this segmentation. Among the following named parameters, only
family
is for use withtype = "dend"
; all others are fortype = "dend"
.- seg_depth
an integer. How many steps down the segmentation hierarchy we use different colors for different groups. If zero (the default), only one color is used that can be specified with
col
passed via...
as usual- palette
a valid name of a hcl palette (one of
hcl.pals()
). Used for coloring the components ifseg_depth
is \(>0\).- pal.extra
an integer. How many extra colors are picked in the specified palette. If this is 0 (the default), palette is used with as many colors as we have components. Since many hcl palettes run from dark to light colors, the last (few) components may be too light. Increasing pal.extra then makes the component colors somewhat more similar, but the last component darker.
- numbers
logical. Shall the stroke numbers be displayed.
- offset
the (x,y)-offset for the numbers relative to the positions from kanjivg saved in the kanjivec object. Either a vector of length 2 specifying some fixed offset for all numbers or a matrix of dimension kanjivec$nstrokes times 2.
- family
the font-family for labeling the nodes if
type = dend
. See details.- lwd
the usual line width graphics parameter.
- ...
further parameters passed to
lines
iftype = "kanji"
and toplot.dendrogram
iftype = "dend"
.
Details
Setting up nice labels for the nodes if type = "dend"
is not easy. For many
font families it appears that some "kanji components" cannot be displayed in plots
even with the help of package showtext
and if the
font contains glyphs for the corresponding codepoints that display correctly in text documents.
This concerns in increasing severity of the problem Unicode blocks 2F00–2FDF (Kangxi Radicals),
2E80–2EFF (CJK Radicals Supplement) and 31C0–31EF (CJK Strokes). For the strokes it seems
nearly impossible which is why leaves are simply annotated with the number of the strokes.
For the other it is up to the user to find a suitable font and pass it via the argument
font family. The default family = NULL
first tries to use default_font
if this option has been set (via kanjistat_options
) and otherwise
uses wqy-microhei
, the Chinese default font that comes with package showtext
and cannot display any radicals from the supplement.
On a Mac the experience is that "hiragino_sans" works well. In addition there is the issue of
font size which is currently not judiciously set and may be too large for some (especially
on-screen) devices. The parameter cex
(via ...
) fixes this.