ggplot2 map: change shape of points

22 views
Skip to first unread message

Ross

unread,
Dec 8, 2012, 4:29:43 AM12/8/12
to ggp...@googlegroups.com
Following code produces a world map with points:

library(maps)
library(ggplot2)
world<-map_data('world')

myData <- data.frame(coordsx=c(98.6121321,  76.7864778,  92.7209357,   0.7608332,   1.6000000,  45.3177332, 102.0901371,  76.5475929, -3.9295275, -2.8162432), 
coordsy=c(50.759610, 25.029751, 53.080824, 25.063100, 22.258565, 57.669511, 56.457415, 57.525077, 57.546489, -7.682919), 
myShapes=c(rep('A',5), rep('B',5)))

(myMap<- ggplot(legend=FALSE) +
   geom_polygon(data=world, aes(x=long, y=lat,group=group), fill='darkgrey') +
   geom_point(data=myData,aes(coordsx,coordsy), shape=myData$myShapes, size=4) +
   coord_cartesian(xlim=c(-30,170),
                   ylim=c(-70,90)) +
   labs(x='Latitude', y='Longitude'))

I need this (photoshoped) plot:


Note the triangles are now circles, and vice versa. How can I change shape of points (without reordering dataframe)?
 
Reply all
Reply to author
Forward
0 new messages