Is it me or do my plots look low quality?

10,266 views
Skip to first unread message

jyr...@gmail.com

unread,
Mar 28, 2016, 5:00:29 PM3/28/16
to ggplot2

Hi everyone, I'm new to R and ggplot2 so I'm not 100% sure what to expect but I certainly feel like something is off. Can someone confirm if what I'm seeing is unusual and if so, what I can do about it?


This is the first plot:

ggplot(diamonds, aes(carat,price)) + geom_point() + geom_smooth()

Look at that blue line - is it supposed to be that pixely and jagged?


This second one is:

ggplot(diamonds, aes(carat,price)) + stat_binhex(bins = 10)

Firstly, the little lines between the bins are missing but also look at the edges, again, very jagged.


I can add colour="gray" to it but the lines will remain jagged.


And another example(this one is a pain to replicate, sorry, but the point remains) is the fourth chart down from this turorial: http://thedatagame.com.au/2015/09/27/how-to-create-nba-shot-charts-in-r/


Mine looks like this: 

Are the little circles round and smooth "enough" there?

I'm using the latest version of R and ggplot2 on Windows 10. Anyone have any ideas?

Cheers,
Mart

Brandon Hurr

unread,
Mar 28, 2016, 5:14:43 PM3/28/16
to jyr...@gmail.com, ggplot2
I'm on mac so I'm not sure so much with Windows, but when I get this sometimes on quartz() I increase the dpi argument and it goes away. 

Looks like this page might be helpful. 






--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Konstantinos L. Papageorgiou

unread,
Mar 28, 2016, 5:32:12 PM3/28/16
to jyr...@gmail.com, ggplot2
nice plots..
you could export the images with a higher resolution (width x height)
a relevant resource about antializing http://www.r-bloggers.com/exporting-nice-plots-in-r/
you could also export the images in pdf and apply further processing in other programs like illustrator, photoshop

jyr...@gmail.com

unread,
Mar 28, 2016, 5:57:43 PM3/28/16
to ggplot2, jyr...@gmail.com, k...@eworx.gr
Thanks guys, anti-aliasing in png exports did seem to be the key problem here. Looks like I have a lot to learn. For now exporting as pdf and going from there fixes the issue.

David Ruvolo

unread,
Apr 8, 2016, 11:15:17 AM4/8/16
to ggplot2, jyr...@gmail.com
ggsave is another option. See http://docs.ggplot2.org/0.9.2.1/ggsave.html for further details.

For example:
# plot carat and price
myplot <- ggplot(data = diamonds, aes(x = carat, y = price)) +
    geom_point() +
    geom_smooth()

# save plot
ggsave(myplot, file = "myplot.png", dpi = 700) # adjust dpi accordingly

Thiago V. dos Santos

unread,
Apr 12, 2016, 2:22:50 PM4/12/16
to jyr...@gmail.com, ggplot2
I hope this is not a late reply, but my workflow to save optimal pictures from within R is the following:

1) copy the figure straight from the graphic device to a pdf file, using "dev.copy2pdf": dev.copy2pdf("image.pdf", width=8.5, height=11)
2) use imagemagick to convert the pdf into a high-res png, using this command: convert -density 600 image.pdf image.png
3) optional - also with imagemagick, remove all the white borders and leave only the contents that matter: convert image.png -trim image_trimmed.png
 
Hope this helps,
 -- Thiago V. dos Santos

PhD student
Land and Atmospheric Science
University of Minnesota


Reply all
Reply to author
Forward
0 new messages