label_fill_JamPolygon | R Documentation |
Arrange one or more text labels to fit inside a polygon.
label_fill_JamPolygon(
jp,
labels,
buffer = -0.15,
relative = TRUE,
color = "black",
border = NA,
ref_jp = NULL,
xyratio = 1.1,
fontsize = 10,
cex = 1,
degrees = 0,
dither_cex = 0.04,
dither_color = 0.07,
dither_degrees = 0,
apply_n_scale = TRUE,
label_method = c("hexagonal"),
draw_labels = TRUE,
seed = 1,
plot_style = c("base", "gg", "none"),
verbose = FALSE,
...
)
jp |
|
labels |
|
buffer |
|
relative |
|
color |
|
border |
|
ref_jp |
|
xyratio |
|
fontsize |
|
cex |
|
degrees |
|
apply_n_scale |
|
label_method |
|
draw_labels |
|
seed |
|
plot_style |
|
verbose |
|
... |
additional arguments are passed to internal functions:
|
`dither_cex , dither_color , dither_degrees` |
values used to provide some variability to the repeated pattern of text labels.
|
This function is intended to define points inside a polygon area so that text labels can be roughly evenly spaced, with relatively good default positioning to minimize overlapping labels. This function does not prevent overlapping labels, nor does it fully prevent labels overlapping the polygon border.
There are options to help minimize overlapping labels, such as xyratio
which defines the default width-to-height ratio of resulting points.
For wider text labels, a higher value for xyratio
may be helpful.
To minimize adjacent (side-by-side) label overlaps, it can be helpful
to use degrees
to rotate labels slightly, for example degrees=5
may be enough to prevent wide labels from overlapping the next label
beside it.
Determine bounding box with rectangular area that encompases the polygon.
Define evenly spaced points across the rectangular area sufficient
to produce at least n
total points.
Retain only the subset of points which are inside the polygon.
If there are fewer than n
remaining points, repeat the process
using a higher target value for n
.
Modify options that plot the result so they work together with
plot.JamPolygon()
.
list
when there are valid coordinates, NULL
otherwise.
The list
contains these elements:
"items_df"
: a data.frame
with columns
x,y,text,rot,color,fontsize,border
"g_labels"
: a grid grob
graphical object only when
plot_style="base"
, otherwise NULL
"scale_width"
: a numeric
value indicating the buffer
used
"jp_buffer"
: a JamPolygon
object after adjusting with buffer
Other JamPolygon:
JamPolygon-class
,
Venndir-class
,
[,JamPolygon,ANY,ANY,ANY-method
,
add_orientation_JamPolygon()
,
area_JamPolygon()
,
bbox_JamPolygon()
,
buffer_JamPolygon()
,
check_JamPolygon()
,
check_Venndir()
,
eulerr_to_JamPolygon()
,
farthest_point_JamPolygon()
,
find_venn_overlaps_JamPolygon()
,
has_point_in_JamPolygon()
,
intersect_JamPolygon()
,
label_outside_JamPolygon()
,
label_segment_JamPolygon()
,
labelr_JamPolygon()
,
minus_JamPolygon()
,
nearest_point_JamPolygon()
,
nudge_JamPolygon()
,
plot.JamPolygon()
,
point_in_JamPolygon()
,
polyclip_to_JamPolygon()
,
polygon_circles()
,
polygon_ellipses()
,
sample_JamPolygon()
,
split_JamPolygon()
,
union_JamPolygon()
,
update_JamPolygon()
df3 <- data.frame(name=c("polygon1", "polygon2"),
label=c("polygon1", "polygon2"),
x=I(list(
list(c(1, 6, 6, 1),
c(2, 5, 5, 2),
c(3, 4, 4, 3)),
list(#c(11, 16, 16, 11),
c(12, 15, 15, 12),
c(13, 14, 14, 13))
)),
y=I(list(
list(c(1, 1, 6, 6),
c(2, 2, 5, 5),
c(3, 3, 4, 4)),
list(#c(1, 1, 6, 6),
c(2, 2, 5, 5),
c(3, 3, 4, 4))
)),
fill=c("gold", "firebrick"))
jp3 <- new("JamPolygon", polygons=df3);
plot(jp3);
lfj <- label_fill_JamPolygon(jp3[1,], labels=1:20)
lfj12 <- label_fill_JamPolygon(jp3, labels=1:20)
plot(lfj$items_df[, c("x", "y")], cex=0)
text(lfj$items_df[, c("x", "y")], labels=lfj$items_df$text)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.