I am just a beginner here, so I apologize in advance for what may seem
as an easy question to you.
I am trying to plot/superimpose/overlay a pie chart onto the map of
Ukraine. I was able to produce a map and plot a dot plot on it. I was
also able to plot a trial pie chart separately from the map. Now, how
do I combine the two?
Your help would be greatly appreciated,
Yuliia
Please find my code below:
mappp<-ggplot()
mappp <- mappp + geom_polygon( data=mapwregions, aes(x=long, y=lat,
group = group),colour="black", fill="grey60" )
mappp #builds a map on a lang/long plot
mydata <- read.csv("trial.csv", header=TRUE, row.names=1, sep=",") #I
am uploading my data file
mappp <- mappp + geom_point(data=mydata, aes(x=long, y=lat,
size=number_of_respokanje <- c(37, 101, 200)), color="red1")
+scale_area(to = c(20, 35))
mappp <- mappp + geom_text( data=mydata, hjust=0.5, vjust=-0.5,
aes(x=long, y=lat, label=label), colour="black", size=4 )
mappp
p=ggplot(data=zz, aes(x="", y="", fill=Resp_Distr)) +
geom_bar(width=1) + coord_polar("y")
pie <- ggplot(data, aes(x = factor(1), fill = cluster, weight=size)) +
geom_bar(width = 1) + coord_polar(theta="y")
Anyone? Please? :(
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
I used just some random numbers, in order to see if it will work at
all and to understand the syntax/logic of the script.
I also think I also gave the wrong code for the pie chart. It should
be:
data <- data.frame(Response = paste(c("akanje","okanje","inbetween")),
size =c(60, 24, 16))
dpie <- ggplot(data, aes(x = factor(1), fill = Response, weight=size))
+ geom_bar(width = 1) + coord_polar(theta="y")
myplot = dpie + opts(title ="Responses Distribution")
myplot


Thank you!However, when trying to download the package I got this message:
"package ‘ggmap’ is not available (for R version 2.14.0)"
Here's a simple proof of concept (using the new package ggmap) -
library(ggmap)ukraine <- qmap(location = 'ukraine', fullpage = TRUE)n <- 10fake_data <- factor(gl(3, n, label = c('a','b','c')))[sample(3*n,.50*3*n)]f_df <- data.frame(x = factor(1), y = fake_data)pie <- qplot(x, y, data = f_df, geom = 'bar', fill = y) +coord_polar(theta = 'y') + theme_nothing()vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)grid.newpage()pushViewport(viewport(layout = grid.layout(19,19)))print(ukraine, vp = vplayout(1:19, 1:19))print(pie, vp = vplayout(10, 10))The bottom part is how you simply push to the viewports, if that is what you're looking to do.... The plot that you are trying to do with the polygon stuff is done the same way.Cheersdavid.
<pie on map.png>
--
Sincerely,Yuliia

Thanks, that should have been obvious! I have copied the proof exactly however, now the error is:Error: stat_count() must not be used with a y aesthetic.I
library(ggplot2)library(dplyr)library(ggmap)