The gauge_*
family of functions is similar to scale_*
though there are some stark differences in places.
See motif vignette for examples of built-in color palettes.
You can gauge aspects specific aspects, just like in ggplot2.
You can also pass a JavaScript function to the gauge. The function must be wrapped in htmlwidgets::JS
, the function must accept as argument the aspect variable used.
callback <- htmlwidgets::JS(
"function(dist){
if(dist > 50)
return 'green';
return 'red';
}"
)
g2(cars, asp(speed, dist, color = dist)) %>%
fig_point(asp(shape = "circle")) %>%
gauge_color(callback) %>%
legend_color(FALSE)
To use a variable as gauge (e.g.: size, or color) and hide the legend pass a boolean to the appropriate legend_*
function.
g2(cars, asp(speed, dist, size = dist)) %>%
fig_point() %>%
legend_size(FALSE)
Defaults:
By default g2r defines two options for the axis used in the chart.
One can also gauge the x and y axis.
g2(cars, asp(speed, dist)) %>%
fig_point() %>%
fig_smooth(method = "polynomial") %>%
gauge_y_log()