ggsave nested ggplots

Hi all

With regards an earlier post of mine: purrr + ggplot: How to add titles - #2 by Nilafhiosagam

I was able to create a nested tibble of ggplots and print them, but I don't seem to be able to save them to .png

I am using the following

walk2(my_graphs$graph_title, my_graphs$graphs,
    ~ggsave(filename = paste0(.x, ".png"), plot = .y))

and get the following output in the console:
Saving 8.96 x 5.56 in image
Saving 8.96 x 5.56 in image
Saving 8.96 x 5.56 in image
Saving 8.96 x 5.56 in image

but nothing actually saves

This is due to the special characters in the titles, that are not accepted in filenames. It seems to work if I use this title2 as filename: title2 = str_replace(graph_title, " : ", "_") (on Windows 10; it could be system-dependent).

1 Like

Ah thank you! I was focused on the wrong part of the code

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.