Created
March 20, 2014 16:47
-
-
Save chrisnatali/9668372 to your computer and use it in GitHub Desktop.
quick plot of graph to png file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_g_plot <- function(g, id, transform=FALSE) { | |
# get coords in mercator proj | |
png(paste("plots/plot", id, ".png", sep=""), | |
type="cairo-png", | |
width=1000, height=1000) | |
if(transform) { | |
vec_df <- get.data.frame(g, what="vertices") | |
xy <- vec_df[,c("X", "Y")] | |
coordinates(xy) <- ~X+Y | |
proj4string(xy) <- CRS("+proj=longlat +ellps=WGS84") | |
xy <- spTransform(xy, CRS("+proj=merc +ellps=WGS84")) | |
plot(g, layout=xy@coords, vertex.size=4, edge.arrow.size=1) | |
} else { | |
plot(g, vertex.size=4, edge.arrow.size=1) | |
} | |
dev.off() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment