I have long axis title names in a ternary plot coded in ggtern
. I cannot get the R and L (baseline) titles to move in (from where they are cut off). The top title looks great, but the other two do not.
I have tried to use axis.title.x = element_text(margin = margin(t = 0, r = 0, b = 0, l = 0))
and changed the positioning variables, but that didn't seem to work. So I'm at a loss as to what to do.
#library(tidyverse)
#library(ggtern)
confidencebreaks <- c(0.95)
x <- runif(1000,min = 0, max = 1)
y <- runif(1000,min = 0, max = 1)
z <- runif(1000,min = 0, max = 1)
df <- tibble(x,y,z)
tern1 <-
ggtern(data = df,
mapping = aes(x = z, y = y, z = z)
) +
labs(title = "A title",
subtitle = "A subtitle",
x = expression(paste(atop("Title 2",
"A long line 2 that goes on and on"))),
y = expression(paste(atop("Title 0",
"A long line 2 that goes on and on"))),
z = expression(paste(atop("Title 1",
"A long line 2 that goes on and on")))
) +
theme(axis.title = element_text(size=10))
print(tern1)
The code above reproduces the problem with the cut off and long axis titles. I would like to be able to shift the long axis titles for "Title 2" and "Title 1" inwards, but have not managed to do so.
So to adjust the labels on ggtern, you should use tern.axis.title and the specification for which side which is R for right, L for left, and T for Top. In your question, you can adjust the labels as follows then
library(tidyverse)
library(ggtern)
confidencebreaks <- c(0.95)
x <- runif(1000,min = 0, max = 1)
y <- runif(1000,min = 0, max = 1)
z <- runif(1000,min = 0, max = 1)
df <- tibble(x,y,z)
df
ggtern(data = df,
mapping = aes(x = z, y = y, z = z)
) +
labs(title = "A title",
subtitle = "A subtitle")+
xlab("Title 2 \n A long line 2 that goes on and on")+
ylab("Title 0 \n A long line 2 that goes on and on")+
zlab("Title 1 \n A long line 2 that goes on and on")+
theme(tern.axis.title.L = element_text(hjust = 0),
tern.axis.title.R = element_text(hjust = 1))