Reputation: 1127
I have a plot where I have introduced vertical x axis labels via las = 2
. Those labels are words. Category words. These words are too long, they range out of the picture. I have no main title in my plot (not needed), so there is enough room at the top of the image. But how do I shift everything up? I find code for parameters called mai
and mar
. But they do not change anything.
I tried to use mar by setting the third value of mar
("top") to 0. So I want 0 margin at the top. But the plot stays where it is :/
Here is my code (german words for the x labels):
categories <- c("Introvertiert", "Selbstbewusst", "Kooperativ", "Ehrgeizig",
"Einfühlsam", "Autoritär", "Temperamentvoll", "Flexibel", "Tolerant", "Teamfähig",
"Zielorientiert", "Überheblich", "Vielseitig", "Ungeduldig", "Zuverlässig", "Eigensinnig",
"Anpassungsfähig", "Souverän", "Selbstkritisch", "Entscheidungsfreudig", "Intelligent",
"Kontaktfreudig", "Kreativ", "Stressresistent", "Hilfsbereit", "Emotional",
"Kompromissbereit", "Gesellig", "Standhaft", "Pünktlich", "Unruhig", "Tatkräftig",
"Aufgeschlossen", "Fröhlich", "Zuvorkommend", "Uneigennützig", "Selbstbeherrscht",
"Schüchtern", "Freundlich", "Sprachgewandt")
x <- seq(1,40)
y <- seq(1,40)
plot(x,y,xaxt="n",main="", mar=c(5, 4, 0, 2) + 0.1, xlab ="")
axis(1, at=1:40, labels=categories, las = 2, cex.axis = 0.8)
Upvotes: 2
Views: 16513
Reputation: 132576
Use par
:
#save old settings
op <- par(no.readonly = TRUE)
#change settings
par(mar=c(8, 4, 2, 2) + 0.1)
plot(x,y,xaxt="n",main="", xlab ="")
axis(1, at=1:40, labels=categories, las = 2, cex.axis = 0.8)
#reset settings
par(op)
Upvotes: 11