Showcasing ggplot2 with AI
I was refactoring some old R code to update a ggplot2 object using GPT-6 Astra, and I was impressed by the result. This made me curious about the extent to which AI models can create something visually pleasing with ggplot2 from scratch and, if so, how much variation there is across different models.
I gave a series of models the same prompt, and below you will see the results. I did not care about the quality of the code (in some cases it was, as expected, very weird), so I will not bother sharing the actual scripts (there is already enough sloppy code on the World Wide Web). Here is the prompt:
Write R code for a ggplot2 object that showcases how great ggplot2 is for creating beautiful figures. Import no packages other than ggplot2 for this task. Save the figure as a PNG file.
Notice that I do not ask it to create a specific type of figure or use a particular dataset for this task. I also make it clear that it should not import any other packages to make sure we are working only with base R and ggplot2. All of these were created without relying on any other packages within the ggplot2 ecosystem.
In general, I believe the output shows how versatile ggplot2 is. The figures demonstrate the layered grammar and how you can create different types of visualisations with ggplot2. And of course, how AI can relatively easily help you create such figures. I will never use AI to remove the legend when I know that I can just use theme(legend.position = "none"), but I do not see any reason why people new to ggplot2 should spend time trying to memorise such code when AI tools can easily help write the code.
I prefer the style provided by GPT-6 Astra (and it also shows that you do not need to import any other packages to create a good-looking ridgeline plot), but I also found the night-sky figure from Grok 4.6 quite impressive. None of the figures are perfect, but they are pretty good. Notably, there are specific models I do not use (e.g., Fable 5.1), but I might add additional examples in the future.
Claude Haiku 4.5

Claude Sonnet 5

Gemini 3.8 Flash

GPT-5.5

GPT-5.6 Luna

GPT-5.6 Sol

GPT-5.6 Terra

GPT-6 Astra

Grok 4.5

Grok 4.6

Kimi K2.7 Code

Kimi K3

MAI-Code-1.1-Flash
