geom-text

Out of order text labels on stack bar plot (ggplot)

笑着哭i 提交于 2019-12-17 21:28:45
问题 I'm trying to make a stacked bar chart with text labels, this some example data / code: library(reshape2) ConstitutiveHet <- c(7,13) Enhancer <- c(12,6) FacultativeHet <- c(25,39) LowConfidence <- c(3,4) Promoter <- c(5,4) Quiescent <- c(69,59) RegPermissive <- c(23,18) Transcribed <- c(12,11) Bivalent <- c(6,22) group <- c("all","GWS") meanComb <- data.frame(ConstitutiveHet,Enhancer,LowConfidence,Promoter,Quiescent,RegPermissive,Transcribed,Bivalent,group) meanCombM <- melt(meanComb,id.vars

annotate boxplot in ggplot2

爱⌒轻易说出口 提交于 2019-12-17 19:44:05
问题 I've created a side-by-side boxplot using ggplot2. p <- ggplot(mtcars, aes(x=factor(cyl), y=mpg)) p + geom_boxplot(aes(fill=factor(cyl))) I want to annotate with min, max, 1st quartile, median and 3rd quartile in the plot. I know geom_text() can do so and may be fivenum() is useful. But I cannot figure out how exactly I can do!. These values should be displayed in my plot. 回答1: The most succinct way I can think of is to use stat_summary . I've also mapped the labels to a color aesthetic, but

Avoid overlapping geom_point and geom_text in ggplot2

送分小仙女□ 提交于 2019-12-13 16:27:50
问题 How can I avoid that these 2 layers in ggplot2 overlap? I try to display the text so that they are not laying above the points. check_overlap does a great job with avoiding that the text overlaps itself, but not with other layers. I also tried the library geom_text_repel , but this library does not support check_overlap and shows the text for every data point. But I need to not have the text for every point, like check_overlap does. ggplot(dat, aes(x = CPI, y = HDI)) + geom_point(aes(color =

R ggplot annotated with atop using three values and bgroup

允我心安 提交于 2019-12-13 13:17:02
问题 Is there any way to annotate a ggplot with three lines one on top of the other, while keeping the text sizes the same across the three lines? I am almost there but the text sizes are different in the third line, it looks like the bgroup is only using the first two lines and I cannot get this right... I am adding the text using to "atop" applications from "?plotmath", which works fine but the text in the third line comes out in a different size compared to the other two lines... library

geom_text on only top part of stacked bar plot

▼魔方 西西 提交于 2019-12-12 08:57:04
问题 I would like to have labels on only the top part of my stacked bar plot. Here is my data frame: #create data frame building <- c("Burj \nKhalifa", "Zifeng \nTower", "Bank of \nAmerica Tower", "Burj Al Arab", "Emirates \nTower One", "New York \nTimes Tower", "Emirates \nTower Two", "Rose Rayhaan \nby Rotana", "The \nPinnacle", "Minsheng \nBank Building") occupiable<- c(585, 317, 235, 198, 241, 220, 213, 237, 265, 237) nonoccupiable <- c(244, 133, 131, 124, 113, 99, 97, 96, 95, 94) df.build <-

R and ggplot: Putting x-axis labels outside the panel in ggplot

丶灬走出姿态 提交于 2019-12-12 04:34:51
问题 Is there a way to bring the labels forward with respect to plot panel in ggplot? Actually I was trying to answer my question here. I have not got any satisfactory response to that one although I thought it would be possible in ggplot. This is an attempt to get a solution although a hacky one. But the labels are rendered below the plot panel here. Following are my (example) data, attempted solution and the resulting plot. library(ggplot2) library(magrittr) mydata = data.frame(expand.grid(Tag =

R ggplot2: Plot percentage values on top of Bar chart with proportion calculated within the geom_bar function

喜欢而已 提交于 2019-12-11 15:25:25
问题 Data used : structure(list(Year = c(2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L), Rating = c(4L, 4L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 5L,

extreme value labels ggplot2 in geom_boxplot

白昼怎懂夜的黑 提交于 2019-12-11 12:12:02
问题 I am trying to add labels to geom_boxplot for extreme values with dplyr and am getting an inconsistency either with ggplot or dplyr. what am i doing wrong? #toy exmaple df=rbind(data.frame(id=rep("1",100),var=paste0("V",seq(1,100)),val=rnorm(100,0,5)), data.frame(id=rep("2",100),var=paste0("V",seq(1,100)),val=rnorm(100,0,3))) #subset with extreme values df_bound=df%.%group_by(id)%.%filter(val<quantile(val,.025)|val>quantile(val,.975)) #plot ggplot(df,aes(x=id,y=val,fill=id,label=var))+geom

How to create unique labels for multiple rows in geom_text?

心不动则不痛 提交于 2019-12-11 06:43:40
问题 I have a data frame like this zip state users longitude latitude 00501 NY 1000 -72.63708 40.92233 00544 NY 1000 -72.63708 40.92233 00601 PR 2000 -66.74947 18.1801 00602 PR 2000 -67.18024 18.36329 I'm plotting number of users using ggmap and geom_point. map<-get_map(location='united states', zoom=4, maptype = "terrain", source='google',color='color') ggmap(map) + geom_point( aes(x=longitude, y=latitude, show_guide = TRUE, colour=users), data=data, alpha=.5, na.rm = T) + scale_color_gradient

Position argument of geom_text to set different tags

丶灬走出姿态 提交于 2019-12-11 05:48:25
问题 I want three tags in each of my stacked bars. One I want it to be at the top of each bar saying the total number of observations per treatment variable (x axis). The other two tags I want them showing the number of observations per gender, to be somehwere in the middle of each Gender option within each treatment variable. I have problems with the geom_text code, since I don't know what position I should try. I have input different options, but when I do, my graph is distorted like this. This