Data visualization in R: Text in the margin

The outer margin of a plot can be used to place some text. The function mtext puts text in the bottom, left, top or right margin, according to the value set in the side parameter.

plot(1,2)
mtext(„text at bottom“, side = 1)
mtext(„text at left“, side = 2)
mtext(„text at top“, side = 3)
mtext(„text at right“, side = 4)

R09_a

In the actual graph the text is very close to the axis. You can move it away from the axis by using the line parameter. The text is moved to the according margin line. Counting starts with zero and goes outwards, away from the axis.

plot(1,2)
mtext(„top 0“, side = 3, line = 0)
mtext(„top 1“, side = 3, line = 1)
mtext(„top 2“, side = 3, line = 2)
mtext(„top 3“, side = 3, line = 3)

R09_b

Werbung
Dieser Beitrag wurde unter R veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit deinem WordPress.com-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s