I am generating some test images which are supposed to have foreground and background colors only. I created my plots using ggplot2, and I saved them using the methods jpeg() and png(). But I realized that the output is not B&W. Below you can see a sample image and the issue as well.
[A sample image]

[Zoomed-in to show the none B&W output]
How can I save a plot like that as a B&W image? (I prefer to stick to JPEG format.)
You can use the option antialias = "none". For example
library(ggplot2)
library(cowplot)
png(antialias = "none")
ggplot(data.frame(x=1:100, y=sin((1:100/10))), aes(x,y)) +
geom_line()
dev.off()

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With