Extra Beschriftungen zu Abbildungen - werden zu bestehender Grundabbildung hinzugefügt bzw. ergänzen sie - zunächst Grundabbildung (high level command) generieren - im Prinzip egal welcher Typ von Abbildung
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
Prinzip: Koordinaten und String angeben ev. noch Größe, Rotation etc. Koordinaten richten sich nach der Basisabbildung und können komfortabel ermittelt werden über locator(1), was die Koordinaten des nächsten Mausklicks in der Abbildung zurückliefert.
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
# erst x-Wert, dann y-Wert
text(2.5, 120, # Koordinaten
'sig. Unterschied', # auszugebender Text
cex=0.7 # Ausgabegröße ist 70% der Standard-Textgröße
)
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
# zwei Zusatzlinien
lines(c(2.15, 1.95), c(117,111))
lines(c(2.60, 3.20), c(117, 91))
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
text(1.8, 95, 'Lacher', cex=1.5, srt=90)
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
arrows(0.65, 120, 3.15, 125)
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
arrows(0.65, 102, 0.65, 109, # x1, y1, x2, y2 Koordinaten
lwd=5, # 5-fache Strichstärke
angle=70 # Pfeil-Flügel in stumpfem Winkel
)
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
symbols(3.4, 125, # x, y Koordinaten des Mittelpunktes
circles=c(0.2), # Radius des Kreises
add=T, # zu bestehender Grafik hinzufügen
inches=F, # Skalierung richtet sich nach Achse
lwd=2 # Strichstärke
)
# the base plot
barplot(c(100,110,90), col='white', ylim=c(80,130), xpd=F)
# x, y coordinates
text(2.5, 120, # coordinates
'sig. Unterschied', # text to put
cex=0.7 # relative font size, here 70% of standard font size
)
# two extra lines
lines(c(2.15, 1.95), c(117,111))
lines(c(2.60, 3.20), c(117, 91))
# we write vertically
text(1.8, 95, 'Lacher', cex=1.5, srt=90)
# an arrow
arrows(0.65, 120, 3.15, 125)
# a thick arrow
arrows(0.65, 102, 0.65, 109, # x1, y1, x2, y2 coordinates
lwd=5, # line width 5 times the normal
angle=70 # angle of arrow whiskers
)
# an additional circle
symbols(3.4, 125, # x, y coordinates of the center
circles=c(0.2), # radius
add=T, # add to existing plot
inches=F, # scaling
lwd=2 # width of lines
)
Nur als Syntax-Beispiel, sie werden nicht ausgeführt und gerendert.
# Koordinaten in Grafik ermitteln
locator() # wartet auf Mausklick
# in der Grafik und liefert Koordinaten zurück
# Abbruch mit rechtem Mausklick
locator(2) # wartet auf genau zwei Mausklicks in Grafik - z. B. für Pfeile
text(locator(1), 'Position mit Maus gefunden', adj=0)
# Fontgröße dauerhaft ändern
# zunächst aktuellen speichern
old.font.size <- par('ps')
# auf 8 Punkt setzen
par(ps=8)
# und in der neuen Größe etwas ausgeben
text(2.5,75,'sig. Unterschied')
# und noch was Großes
par(ps=15) # globalen Parameter Schriftgröße setzen für die folgenden Befehle
text(3,90,'grosse Beschriftung') # und Text ausgeben
# und alte Größe wieder einstellen
par(ps=old.font.size)
# aber senkrecht bitte
par(srt=90)
text(0.5,15,'Alte Font-Größe')
Version: 22 April, 2021 09:52