Customising the axis is done using two families of functions,
axis_. It’s admittedly sometimes when one should use which, hopefully this part of the API will be made easier soon. In the meantime, one has to contend with it and use the few convenience function that attempt at easing the customisation of axis.
The reason for this is that, in a sense, G2.js distinguishes between 1) the axis themselves and 2) the variables that are plot against them; hence the use of two separate functions (
library(g2r) data(penguins, package = 'palmerpenguins') g2( penguins, asp(bill_length_mm, flipper_length_mm, color = species) ) %>% fig_point() %>% fig_smooth() %>% gauge_y_pow()
Axis titles can be set with the convenience functions
To hide axis one can pass a boolean to the
axis_* functions or, to hide both
df <- data.frame( name = c("Banana", "Apple", "Coconut", "Orange"), value = c(1, .8, .4, .1) ) g2(df, asp(name, value, color = name)) %>% fig_interval( asp(shape = "pyramid"), adjust("symmetric") ) %>% coord_transpose() %>% coord_scale(1, -1) %>% axis_hide()
To customise anything else one has to use the
axis_* functions. The documentation on the available arguments is on the official website.