I'm having a trouble with saving the plots as jpeg or pdf format from R kernel of Jupyter Notebook.
Here's the code,
pdf("Hatdog.jpeg")
plot(x,y, col="green")
dev.off()
I was wondering why the image is corrupted, which when I tried to open the actual file, it states that It looks like we don't support this file format.
Anyone having the same issue? How did you solved it? Thanks.
You are saving a pdf file with a -.jpg extension? To save as a jpeg:
# 1. Open jpeg file
jpeg("rplot.jpg", width = 350, height = 350)
# 2. Create the plot
plot(x = my_data$wt, y = my_data$mpg,
pch = 16, frame = FALSE,
xlab = "wt", ylab = "mpg", col = "#2E9FDF")
# 3. Close the file
dev.off()
To save as a pdf:
# Open a pdf file
pdf("rplot.pdf")
# 2. Create a plot
plot(x = my_data$wt, y = my_data$mpg,
pch = 16, frame = FALSE,
xlab = "wt", ylab = "mpg", col = "#2E9FDF")
# Close the pdf file
dev.off()
(from http://www.sthda.com/english/wiki/creating-and-saving-graphs-r-base-graphs)
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