Is it possible to handle the size or rotate of the x and y axis text?
I would like to change the size or rotate the axis text, but I don't see any example to see how can I do it. I really appreciate the help with that.
Hi @ManuelSpinola, you can control all the axis options with axis_x() and axis_y(). You can see the docs here to know what options can be applied to the axis labels.
If you're not familiar with it, the way to pass options can look a bit strange because it uses nested lists. The idea is that you must make a list for each "option level". For example, to increase the font size, the docs says that for the AxisOption, you go to label, then to style, then to fontSize (in shapeAttrs), so the corresponding code is:
axis_y(
label = list( # level 1
style = list( # level 2
fontSize = 30 # level 3
)
)
)
You can do something similar to rotate labels. Here's an example with bigger font size and rotated labels:
library(g2r)
df <- data.frame(
x = letters,
y = runif(26)
)
df$max <- 1
g2(df, asp(x, y), elementId = "x") %>%
fig_interval(asp(y = max), fill = "lightgrey") %>%
fig_interval(asp(, size = 8)) %>%
gauge_y_linear(min = 0, max = 1) %>%
axis_x(
label = list(rotate = 300, offset = 10)
) %>%
axis_y(
label = list(style = list(fontSize = 30))
)
