0

In the example to compare plot model results from many different resampled tidymodels, how can I change the labels of the x-axis ticks?

autoplot(
   grid_results,
   rank_metric = "rmse",  # <- how to order models
   metric = "rmse",       # <- which metric to visualize
   select_best = TRUE     # <- one point per workflow
)

I have tried it for instance with + scale_x_discrete(labels = rep("example", 12)) as an extension to the autoplot object but the plots did not show any labels in this case.

The example refers to the first image under this link, heading: 15.3 TUNING AND EVALUATING THE MODELS

S Front
  • 333
  • 1
  • 8
  • 1
    Try with `scale_x_continuous(breaks = 1:12, labels = rep("example", 12))`. From the picture in the link you posted I would guess that the x -axis var is a numeric. – stefan Jun 25 '21 at 10:47
  • thank you. My bad, I didn't realise. Because I am unfamiliar with ``autoplot``, I distracted my search by looking for solutions within the options of ``autoplot``. – S Front Jun 25 '21 at 20:49
  • 1
    The `autoplot()` output is a `ggplot` object so you should be able to use (most) ggplot2 functions to modify it, like to change the title, theme, and other characteristics. – Julia Silge Jun 26 '21 at 03:59
  • Thank you so much! Relatedly, I was wondering how I can adapt the labels of facet wraps when plotting several metrics at once. It seems that wen using ``autoplot`` and ``facet_wrap`` to change the labels with ``labeller``, it is difficult for me to access the nested elements in the metrics list and specifically the metric column. Any suggestions how to approach this? – S Front Jun 28 '21 at 06:01

0 Answers0