How to get rid of "noise" in a plot image

82 views Asked by At

What could I do, so the plot doesn't lose quality, after it is automatically saved?

The following code will be an example of plot and save:

data.barplot <- c(80L, 60L, 80L, 40L, 40L, 0L, 80L)

jpeg("/home/machina/Dropbox/Vitor-IC/graficos/teste.jpeg",width = 2600, height = 2800, quality = 100, pointsize = 70)
barplot(data.barplot, ylab = "Percentage: Days of Holidays", names.arg = c("Sun","Mon", "Tue", "Wed","Thu", "Fry", "Sat"))
title(main="Title Here",outer=T, cex.main = 2.4)
dev.off()

The result was a very bad quality image. Thus, could you help me improve it, so it can barely be pleasurable to see?

The generated image is the one bellow.

Note:

I played with the input variables in jpeg function such as quality, res, height, width, pointsize, but didn't get the improvement I was aiming for barplot

1

There are 1 answers

0
Kevin Cazelles On BEST ANSWER

The default units is pixel units=px meaning you cannot increase the quality by using res (for instance) because the number of pixels is constant!

Change the units, for instance:

data.barplot <- c(80L, 60L, 80L, 40L, 40L, 0L, 80L)
#
jpeg("teste.jpeg",width = 7, height = 7, units = "in", res = 300)
barplot(data.barplot, ylab = "Percentage: Days of Holidays", names.arg = c("Sun","Mon", "Tue", "Wed","Thu", "Fry", "Sat"))
title(main="Title Here")
dev.off()

Now, increasing res will change the number of pixels and thereby the quality of your image (and the size of the file), try res=600.

Hope this will be of help.