r,ggplot2,pie-chart,facet,geom-text
It's better to achieve the desired result by creating a position variable (as I also showed in this answer). Applying this method to your situation: # creating the position variable library(dplyr) df <- df %>% group_by(id) %>% mutate(pos=cumsum(value) - 0.5*value) # creating the plot ggplot(df, aes(x = factor(1), fill =...
This works for me: require(ggplot2) g <- ggplot(cars, aes(speed, dist), color='blue') g <- g + geom_point(size=0.8) g <- g + geom_text(aes(y=25, x=5, label=paste("sigma == 1"), size=1.5), hjust=0, parse=TRUE, color='blue') g <- g + scale_y_log10() g http://www.r-fiddle.org/#/fiddle?id=GVWg1dDO...
Okay, I spotted several shortcomings in the ggplotly conversion. For now, I can suggest the following workaround: mappts2 <- ggplot(citiesC, aes(x=lon, y=lat)) + geom_text(size=10, aes(label=cityname), hjust=0, vjust=0) + borders(regions="canada", name="borders") + coord_equal() + geom_point(aes(text=cityname, size=indM), colour="red", alpha=0.5, name="cities", label=citiesC$cityname) # Take a look mappts2 # Yes, text is too big...
First, simply add color = "power1" and color = "power2" to the respective geom_text() calls. This will set the appropriate color, but give you a nasty (but expected) "a" in your legend. To remove the "a" text, add show_guide=FALSE to each of the geom_text() calls. Second, I believe you want...
Try this library(ggplot2) cl <- kmeans(iris[, 1:2], 3, nstart = 25) ggplot(transform(iris[, 1:2], cl = factor(cl$cluster)), aes(x = Sepal.Length, y = Sepal.Width, colour = cl)) + geom_point() + scale_colour_manual(values=c("purple", "green","orange")) + annotate("point", x = cl$centers[, 1], y = cl$centers[, 2], size = 5, colour = c("purple", "green","orange")) + annotate("text", x...
This should do it: g <- ggplot(data=df, aes(x=a,y=b)) + geom_point() g + annotate("text", x=5,y=4,parse=TRUE, label="beta==1.00 * ' p<0.0001'") It's a matter of splitting the label with single quotes to the side of the whitespace and connecting two label bits with *. You also need the == for equals to. ...
In order for position_dodge to work, there needs to be a reason to dodge. That is you need to change the ann_text appropriately with variable = c("LF", "HF"), so that there is a reason to dodge. Then just define the label appropriately. Below I assume you just want the *...
Use hjust=0.5 in geom_text() and pad the labels for positive numbers appropriately, i.e. prepend space characters to obtain labels of equal length: df_graph$text <- format(round(df_graph$value, 2)) ...
Move the fill aesthetic to geom_bar and change the y position for geom_text should get you what you want. bar.plot <- ggplot(BarDiff.m.s, aes(x=value.change))+ geom_bar(aes( fill=incompatibility), binwidth=1)+ geom_text(data=num.obs, aes(label=paste("obs=",num.obs),y=4,x= -4)) + labs(x="score differences", y="count / years since start of PSA")+ geom_vline(aes(xintercept=0), linetype="dotted")+ theme(plot.title=element_text(face="bold", size=10), legend.position= "bottom")+ scale_fill_brewer(palette="Set1")+ facet_grid(years.since.peace ~...