Complete canonical API text; task articles explain the workflows. Tutorials
Site guide · find your task
Setup and learning paths
HomeInstall and prepare the environmentChoose your learning moduleModule I · Chord
1.1 Tables and field meanings1.2 Produce and import comparisons1.3 Build the layers step by step1.4 Direction, curvature and clearance1.5 Filter and summarize links1.6 Full source-file workflow1.7 Complete chord showcaseModule II · Collinear
2.1 Reuse chord input tables2.2 Switch coordinates and add layers2.3 Routes, clearance and the ruler2.4 Compare CDS neighbourhoods2.5 Focus, anchors and segments2.6 Complete collinear showcaseModule III · Plasmid
3.1 DNA, annotations and 13 references3.2 From a circle to annotation layers3.3 Features, primers and restriction3.4 Thirteen plasmid references3.5 Complete plasmid casesConsult as needed · Data and layers
Prepare tables and coordinatesImport and convert dataImport nucleotide and protein alignmentsProject protein intervals to genomic coordinatesFeatures, stacking and genomic decorationLabels and local placementQuantitative tracksMappings, scales, guides and themesSet values by sequence and strandCommon adjustments and grammarExport, preview and diagnosticsLearning map and reference
Articles and complete workflowsFunction referenceReproducible galleryFrequently asked questionsMigrate to the candidate APITerminology and design sourcesDevelopment status and changes
Automatically arrange generic feature labels
Source:R/geom-feature-label.R
geom_feature_label_repel.RdAutomatically arrange generic feature labels
Usage
Code
geom_feature_label_repel(
mapping = NULL,
data = NULL,
label_layout = c("feature", "radial", "auto", "callout"),
label_wrap = NULL,
label_fit = c("wrap", "none", "ellipsis", "auto", "shrink"),
label_max_lines = 2L,
label_side = c("outside", "inside", "auto"),
max_overlaps = Inf,
external = TRUE,
position = "identity",
show.legend = FALSE,
inherit.aes = FALSE,
label_min_size = 1.5,
label_segment_overlap = "fade",
label_segment_overlap_alpha = 0.18,
label_segment_linetype = "auto",
...
)Arguments
- mapping, data
Standard layer inputs. Map feature text with
label.- label_layout
One of
"feature","radial","auto", or"callout". The default"feature"follows plasmid-map convention: text is tried inside first, then assigned to a fixed-radius internal track. All non-external text is laid out character by character along its selected track radius rather than rotated as one straight string. A light leader appears when one or more intervening tracks separate the feature and its label. Choose another mode for unrestricted external callouts.- label_wrap, label_fit, label_max_lines
Text fitting controls.
label_fit = "shrink"explicitly uses internal-first placement without truncating the text. Text size is bounded bylabel_min_size; unresolved labels keep their requested font and use adjacent/external placement or hiding. Other fitting modes retain their existing behavior.- label_side
One of
"inside","outside", or"auto".- max_overlaps
Maximum unresolved overlaps.
- external
Whether the staged feature layout may place a label outside the circular backbone after inside and adjacent placement fail. When
FALSE, unresolved labels are hidden instead of pushing inward forever. External labels are rendered as rounded callouts using a lightened form of the feature's resolved fill. When restriction-site labels coexist on a circular map, both retain their own layout semantics but register final boxes in one coordinate-owned exterior track region so they cannot occupy the same space.- position
Feature Position used for the label anchor. In
coord_collinear(), an omitted Position shares the matching feature layer's lanes; an explicit Position changes only label anchors, leaving feature polygons in their own Position. If both inputs contain uniquefeature_idvalues, label inputs may be subsets or reordered; their accession, interval and strand must still agree. Without IDs, inheritance requires the same interval rows in order. Multiple matching geometry layers require an explicit label Position or unambiguous feature IDs.- show.legend, inherit.aes
Standard ggplot2 layer arguments.
- label_min_size
Minimum text size in millimetres for explicit shrink, default 1.5. Must not exceed the requested text size. Original text, requested/final sizes and fitting reason are exported with the label.
- label_segment_overlap
Character, default
"fade". How portions of a leader line covered by another label are drawn:"fade"keeps them at reduced opacity,"clip"removes them, and"show"leaves the complete leader visible. This does not affect text wrapping, ellipsis or label hiding.- label_segment_overlap_alpha
Numeric in
[0, 1], default 0.18. Relative opacity applied only to covered leader-line portions whenlabel_segment_overlap = "fade".- label_segment_linetype
Character or numeric, default "auto". Leader-line linetype.
"auto"draws solid lines, except for labels that were moved to the other side of their arc, which are drawn dashed. Any other valid ggplot2 linetype (e.g."solid","dashed","dotted", or a numeric dash pattern) is used for all leader lines.- ...
Additional text parameters.
Details
Manual label rotation, offsets, orientation and overlap policy belong to
geom_feature_label(). Their label_* controls are rejected by automatic
layers rather than silently ignored.
Examples
Code
library(dplyr)
data(plasmid_example_pUC19)
seqs <- plasmid_example_pUC19 |>
select(accver, length)
feature_source <- find_common_features(plasmid_example_pUC19)
features <- feature_source |>
select(accver, start, end, strand, type, anno)
# ASCII display copy for the default PDF help-example device.
features <- features |>
mutate(anno = gsub("\u03b1", "alpha", anno, fixed = TRUE))
ggchord(seq_data = seqs) +
geom_seq() +
geom_feature(data = features, position = position_plasmid()) +
geom_feature_label_repel(data = features, position = position_plasmid()) +
coord_circular()