Plot the new SVG R logo with ggplot2
[This article was first published on R – rud.is, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
High resolution and SVG versions of the new R logo are finally available.
I converted the SVG to WKT (file here) which means we can use it like we would a shapefile in R. That includes plotting!
Here’s a short example of how to read that WKT and plot the logo using ggplot2:
library(sp) library(maptools) library(rgeos) library(ggplot2) library(ggthemes) r_wkt_gist_file <- "https://gist.githubusercontent.com/hrbrmstr/07d0ccf14c2ff109f55a/raw/db274a39b8f024468f8550d7aeaabb83c576f7ef/rlogo.wkt" if (!file.exists("rlogo.wkt")) download.file(r_wkt_gist_file, "rlogo.wkt") rlogo <- readWKT(paste0(readLines("rlogo.wkt", warn=FALSE))) rlogo_shp <- SpatialPolygonsDataFrame(rlogo, data.frame(poly=c("halo", "r"))) rlogo_poly <- fortify(rlogo_shp, region="poly") ggplot(rlogo_poly) + geom_polygon(aes(x=long, y=lat, group=id, fill=id)) + scale_fill_manual(values=c(halo="#b8babf", r="#1e63b5")) + coord_equal() + theme_map() + theme(legend.position="none") |
To leave a comment for the author, please follow the link and comment on their blog: R – rud.is.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.