Label positions on the plot frame.
This geometry attemps to optimize label positioning so that labels do not overlap, and hides any that would overlap.
x
: X-axis position.
y
: Y-axis position.
label
: Text to render.
position
: One of :dynamic
, :left
, :right
, :above
, :below
, :centered
. If :dynamic
is used, label positions will be adjusted to avoid overaps. Otherwise, labels will be statically positioned left, right, above, below, or centered relative to the point.
hide_overlaps
: If true, and dynamic positioning is used, labels that would otherwise overlap another label or be drawn outside the plot panel are hidden. (default: true)
plot(dataset("ggplot2", "mpg"), x="Cty", y="Hwy", label="Model", Geom.point, Geom.label)
Cty
0
10
20
30
40
a4
a4
a4
a4
a4
a4
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a4 quattro
a6 quattro
a6 quattro
a6 quattro
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
c1500 suburban 2wd
corvette
corvette
corvette
corvette
corvette
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
k1500 tahoe 4wd
malibu
malibu
malibu
malibu
malibu
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
caravan 2wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
dakota pickup 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
durango 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
ram 1500 pickup 4wd
expedition 2wd
expedition 2wd
expedition 2wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
explorer 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
f150 pickup 4wd
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
mustang
civic
civic
civic
civic
civic
civic
sonata
sonata
sonata
sonata
sonata
sonata
sonata
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
tiburon
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
grand cherokee 4wd
range rover
range rover
range rover
range rover
navigator 2wd
navigator 2wd
navigator 2wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
mountaineer 4wd
altima
altima
altima
altima
altima
altima
maxima
maxima
maxima
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
pathfinder 4wd
grand prix
grand prix
grand prix
grand prix
forester awd
forester awd
forester awd
forester awd
forester awd
forester awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
impreza awd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
4runner 4wd
camry
camry
camry
camry
camry
camry
camry
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
camry solara
corolla
corolla
corolla
land cruiser wagon 4wd
land cruiser wagon 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
toyota tacoma 4wd
gti
gti
gti
gti
gti
jetta
jetta
jetta
jetta
jetta
jetta
jetta
jetta
new beetle
new beetle
new beetle
new beetle
passat
passat
passat
passat
passat
passat
passat
a4
civic
civic
civic
grand prix
corolla
corolla
jetta
new beetle
new beetle
0
10
20
30
40
50
Hwy
plot(dataset("MASS", "mammals"), x="Body", y="Brain", label=1,
Scale.x_log10, Scale.y_log10, Geom.point, Geom.label)
Body
10-4
10-2
100
102
104
Arctic fox
Owl monkey
Mountain beaver
Cow
Grey wolf
Goat
Roe deer
Guinea pig
Verbet
Chinchilla
Ground squirrel
Arctic ground squirrel
African giant pouched rat
Lesser short-tailed shrew
Star-nosed mole
Nine-banded armadillo
Tree hyrax
N.A. opossum
Asian elephant
Big brown bat
Donkey
Horse
European hedgehog
Patas monkey
Cat
Galago
Genet
Giraffe
Gorilla
Grey seal
Rock hyrax-a
Human
African elephant
Water opossum
Rhesus monkey
Kangaroo
Yellow-bellied marmot
Golden hamster
Mouse
Little brown bat
Slow loris
Okapi
Rabbit
Sheep
Jaguar
Chimpanzee
Baboon
Desert hedgehog
Giant armadillo
Rock hyrax-b
Raccoon
Rat
E. American mole
Mole rat
Musk shrew
Pig
Echidna
Brazilian tapir
Tenrec
Phalanger
Tree shrew
Red fox
10-1
100
101
102
103
104
Brain
plot(dataset("MASS", "mammals"), x="Body", y="Brain", label=1,
Scale.x_log10, Scale.y_log10, Geom.label(position=:centered))
Body
10-4
10-2
100
102
104
Arctic fox
Owl monkey
Mountain beaver
Cow
Grey wolf
Goat
Roe deer
Guinea pig
Verbet
Chinchilla
Ground squirrel
Arctic ground squirrel
African giant pouched rat
Lesser short-tailed shrew
Star-nosed mole
Nine-banded armadillo
Tree hyrax
N.A. opossum
Asian elephant
Big brown bat
Donkey
Horse
European hedgehog
Patas monkey
Cat
Galago
Genet
Giraffe
Gorilla
Grey seal
Rock hyrax-a
Human
African elephant
Water opossum
Rhesus monkey
Kangaroo
Yellow-bellied marmot
Golden hamster
Mouse
Little brown bat
Slow loris
Okapi
Rabbit
Sheep
Jaguar
Chimpanzee
Baboon
Desert hedgehog
Giant armadillo
Rock hyrax-b
Raccoon
Rat
E. American mole
Mole rat
Musk shrew
Pig
Echidna
Brazilian tapir
Tenrec
Phalanger
Tree shrew
Red fox
10-1
100
101
102
103
104
Brain