geom-text

Labelling and theme of ggalluvial plot in R

百般思念 提交于 2019-12-11 02:34:50
问题 For the past hours I have tried to understand the whole design/theme/labelling concept around ggalluvial , but I failed. Within minutes I was able to produce the kind of graph I want (thanks to the package ggalluvial), but I can't figure how to produce the correct labelling/theme I'd like to have. This is where I am currently: This is where I was initially: To get you to understand where I am, here's a reproducible example I used the following code: library(ggalluvial) ds <- as.data.frame

Change geom_text to bold when parse=TRUE

青春壹個敷衍的年華 提交于 2019-12-10 16:24:13
问题 I am annotating faceted plots to include a superscript, yet am having trouble making the text bold. I realise that this has something to do with creating an expression outside the plot call and then specifying parse=TRUE . There is probably quite a simple solution but so far nothing I have tried has worked, including the use of bquote() and bold() . Thanks library(ggplot2) data(iris) rsq<-c(.3,.6,.75) pos<-c(5,6,7) Species<-levels(iris$Species) big_data<-as.data.frame(cbind(pos, rsq)) big

plotly not getting geom_text in R / ggplot

℡╲_俬逩灬. 提交于 2019-12-10 13:55:37
问题 I have a ggplot that works fine by its own. But when I try to import it in to the plotly api system, the geom_text seems to not work - everything else works. Can anyone help me? Here's my R version - R version 3.1.2 (2014-10-31) and plotly version - 0.5.23 The data that I am using is in file.csv and looks like: Province,Community,General Shelters,General Beds,Mens Shelters,Mens Beds,Womens Shelters,Womens Beds,Youth Shelters,Youth Beds,Family Shelters,Family Beds,Total Shelters,Total Beds New

how to display text on several lines with geom_text in faceting wrap

怎甘沉沦 提交于 2019-12-08 08:09:52
问题 This is my df : df <- data.frame(annee = rep(c(2003,2004), times = 1, each = 3), sps = c("a", "b", "c"), nb = 1:3) I create a column containing my labels : df$labels <- paste("nb", df$sps, "=", df$nb) Then I do my plot : ggplot(df, aes(nb)) + geom_density(aes(fill = sps, colour = sps), alpha = 0.1) + facet_wrap(~ annee) + geom_text(data=df, aes(x=8, y=2.5, label= labels), colour="black", inherit.aes=FALSE, parse=FALSE) But I have a problem with my text in each facet : I would like to have 3

ggplot2 specify geom_text position by conventional “top”, “bottom”, “left”, “right”, “center”

夙愿已清 提交于 2019-12-06 14:29:23
问题 I'm making some graphs in ggplot and cannot figure out how to plot in graph text without specifying x and y positions. Lets say I'm making a graph like this. sp <- ggplot(mpg, aes(hwy, cty, label = "sometext"))+ geom_point() I want to add the label to be printed in the same way in every graph. Calling the following simply prints text at every x, y value supplied to aes . sp + geom_text() I could manipulate the x y data supplied to geom_text() to ensure that the text remained in the same

ggplot2 specify geom_text position by conventional “top”, “bottom”, “left”, “right”, “center”

不羁的心 提交于 2019-12-04 21:41:55
I'm making some graphs in ggplot and cannot figure out how to plot in graph text without specifying x and y positions. Lets say I'm making a graph like this. sp <- ggplot(mpg, aes(hwy, cty, label = "sometext"))+ geom_point() I want to add the label to be printed in the same way in every graph. Calling the following simply prints text at every x, y value supplied to aes . sp + geom_text() I could manipulate the x y data supplied to geom_text() to ensure that the text remained in the same relative position between graphs but is there not a simply way to call position by default positions like

geom_text on only top part of stacked bar plot

被刻印的时光 ゝ 提交于 2019-12-04 11:50: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 <- data.frame(building, occupiable, nonoccupiable) #melt data frame for stack bar plot df.build2 <- melt

Position geom_text in the middle of each bar segment in a geom_col stacked barchart [duplicate]

半腔热情 提交于 2019-12-03 09:34:28
问题 This question already has answers here : Showing data values on stacked bar chart in ggplot2 (2 answers) Closed 3 years ago . I would like to position the corresponding value labels in a geom_col stacked barchart in the middle of each bar segment . However, my naive attempt fails. library(ggplot2) # Version: ggplot2 2.2 dta <- data.frame(group = c("A","A","A", "B","B","B"), sector = c("x","y","z", "x","y","z"), value = c(10,20,70, 30,20,50)) ggplot(data = dta) + geom_col(aes(x = group, y =

Add less than symbol, “<”, to a ggplot via geom_text in R

こ雲淡風輕ζ 提交于 2019-12-03 08:55:51
The short version : How would I make this contrived code plot a proper greek beta character AND the rest of the label string, with the space and the less than character and the numbers formatted as typed? library("ggplot2") df<-data.frame(a=1:15,b=6:20) ggplot(data=df, aes(x=a,y=b)) + geom_point() + geom_text(x=5,y=4,label="beta=1.00 p<0.0001", parse=TRUE) If I leave out the ", parse=TRUE" argument, the string works great, but won't give me a real greek beta. If I leave it in, all hell breaks loose. The long version (and why I can't find a duplicate): I finally discovered in How to use Greek

Position geom_text in the middle of each bar segment in a geom_col stacked barchart [duplicate]

好久不见. 提交于 2019-12-02 23:56:38
This question already has an answer here: Showing data values on stacked bar chart in ggplot2 2 answers I would like to position the corresponding value labels in a geom_col stacked barchart in the middle of each bar segment . However, my naive attempt fails. library(ggplot2) # Version: ggplot2 2.2 dta <- data.frame(group = c("A","A","A", "B","B","B"), sector = c("x","y","z", "x","y","z"), value = c(10,20,70, 30,20,50)) ggplot(data = dta) + geom_col(aes(x = group, y = value, fill = sector)) + geom_text(position="stack", aes(x = group, y = value, label = value)) Obviously, setting y=value/2 for