Persistent invalid graphics state error when using ggplot2

I ran into this same error and solved it by running:

dev.off()

and then running the plot again. I think the graphics device was messed up earlier somehow by exporting some graphics and it didn’t get reset. This worked for me and it’s simpler than reinstalling ggplot2.

Leave a Comment