ggplot2 rename x axis labels code example
Example 1: change label x axis ggplot2
theme(
axis.title = element_text(), # Change both x and y axis titles
axis.title.x = element_text(), # Change x axis title only
axis.title.x.top = element_text(), # For x axis label on top axis
axis.title.y = element_text(), # Change y axis title only
axis.title.y.right = element_text(), # For y axis label on right axis
)
Example 2: change the y ticks in r plot
yticks = c('A', 'B', 'C')
x = c(0, 1, 2, 3, 4, 5)
y = c(1, 2, 3, 2, 1, 3)
plot(y = y, x = x, yaxt = 'n', type='b')
axis(side = 2, at = c(1,2,3), labels = yticks)