search for: geom_text

Displaying 20 results from an estimated 85 matches for "geom_text".

2009 Mar 30
2
ggplot2-geom_text()
Hi: I need help with geom_text(). I would like to count the number of Locations and put the sum of it right above each bar. x <- "Location Lake_dens Fish Pred Lake1 1.132 1 0.115 Lake1 0.627 1 0.148 Lake1 1.324 1 0.104 Lake1 1.265 1 0.107 Lake2 1.074 0 0.096 Lake2 0.851 0 0.108 Lake2 1.098 0 0.095 Lake2 0.418...
2013 Sep 01
1
Blur and not readable text, using geom_text in ggplot
Dear R Users, I am new to ggplot. I am using geom_text to inscribe values on my ggplot but it is giving me values which are unreadable and blur. Please let me know if there is any way out. ----------------- Code ----------------- *es <- es3 + geom_text(data=tmp.cor, aes(x=2, y=min(infer.df$value),* * label=text.bottom), co...
2009 Dec 31
1
ggplot2: How to change font of labels in geom_text
...ew Year everyone. I have what I hope is a simple-to-answer question. In the code sample below, I'm using a tile plot to plot a continuous measure and overlaying the plot with labels. I need to print the labels in courier, but there appears to be no way to override the default font setting in geom_text. I've scoured the web for clues on how to do this, but found nothing relevant. Any help would be very much appreciated. Ronan ---- start code snippet ---- small.df <- data.frame(scan(what=list(row=0, col=0, item="", latency=0))) 1 1 ab 0.1 1 2 bc 0.2 1 3 cd 0.3 2 1 de 0.4 2...
2009 May 16
1
ggplot2: annotating plot with mathematical formulae
Hi, Is there a way of annotating a ggplot plot with mathematical formulae? I can do geom_text(aes(label="some text", ... but I can't do geom_text(aes(label=expression(x^{n-1}), ... It gives the error Error: geom_text requires the following missing aesthetics: label Is there a convenient equivalent? Cheers, Paul
2009 Oct 23
1
ggplot2: stat_bin ..count.. with geom_text when NA is present
One for the ggplot2 gurus... I have a function which makes a plot just fine if the response vector (res in the example; fac1 is a factor) has no NA in it. It plots the data, then makes a little annotation at the bottom with the data counts using: p <- p + geom_text(aes(x = fac1, y = min(res) - 0.1 * diff(range(res)), label = paste("n = ", ..count.. , sep = "")), color = "black", size = 4.0, stat = "bin") If there are NA in the res vector, I get warnings from stat_summary and geom_point about removing ro...
2008 May 27
1
label outliers in geom_boxplot (ggplot2)
...ier values labelled with their "name" attribute. So I did > library(ggplot2) > dat=data.frame(num=rep(1,20), val=c(runif(18),3,3.5), name=letters[1:20]) > p=ggplot(dat, aes(y=val, x=num))+geom_boxplot(outlier.size=4, outlier.colour="green") > p+geom_text(label=dat$name) But this -of course- labels all the data points. So I searched high and low to find the way to only label the outliers, but I couldn't find any solution. Probably my keywords were inappropriate, but I looked at the ggplot website and the book also. So I did this: &g...
2011 Apr 22
1
ggplot
Hello everyone, I am using ggplot to plot but I am getting the following error which I do not understand Error: geom_text requires the following missing aesthetics: label My code is dimx<-256 library(ggplot2) dev.new() xandy<-expand.grid(seq(1:dimx),seq(1:dimy)) xx<-data.frame(xandy[[1]],xandy[[2]],Powermap=Powermap) subsetxx<-subset(xx, xx$Powermap>threshold) ggplot( (subsetxx ) )+...
2017 Jun 27
4
ggplot2 geom_bar arrangement
...d according to the label, which I don't want. I want the bars to appear exactly as they appear in the data frame. For example in the code: Lab=c(letters[4:6],letters[1:3]) valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4) df <- data.frame(Lab,valuex) px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) + geom_bar(stat = "identity") px The default arranges the bars in order 'a' through 'f', but I want them arranged as per df. How can I do this? thanks! [[alternative HTML version deleted]]
2010 Nov 20
2
Merge two ggplots
...p to merge these two plots into one. plot_CR<-function(x,y,agentid,CRagent){   library(ggplot2)     agent<-CRagent[[agentid]] # To make following expression shorter   ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+   geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80))))+   geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour="CRagents[[i]]$sr") } plot_shad_f<-function(f){   library(ggplot2)   plotdata<-melt(f)   names(plotdata)<-c('x','y','z')   v<-ggplot(plo...
2017 Jun 27
0
ggplot2 geom_bar arrangement
...library(ggplot2) Lab = c(letters[4:6], letters[1:3]) valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4) df <- data.frame(Lab,valuex) # set the factor levels to the same order as observed in the data frame df$Lab <- factor(df$Lab, levels=unique(df$Lab)) px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) + geom_bar(stat = "identity") px Jean On Tue, Jun 27, 2017 at 1:43 PM, Brian Smith <bsmith030465 at gmail.com> wrote: > Hi, > > I was trying to draw a geom_bar plot. However, by default, the bars are > arranged according to the label, which I don't wan...
2010 Sep 01
2
ggplot2 multiple group barchart
...quot;m","f","m","f","f") d.data <- data.frame (v1, v2, v3, gender) d.data x <- names (d.data[1:3]) y <- mean (d.data[1:3]) pl <- ggplot (data=d.data, aes (x=x,y=y)) pl <- pl + geom_bar() pl <- pl + coord_flip() pl <- pl + geom_text (aes(label=round(y,1)),vjust=0.5, hjust=4,colour="white", size=7) pl this gives me a nice barchart to compare the means of my variables "v1","v2" and "v3". my question: how do i have to proceed if i want this barchart splittet by the variable "gender&qu...
2011 Nov 10
2
ggplot2 - regression statistics how to display on plot
Hello - So I am trying to use ggplot2 to show a linear regression between two variables, but I want to also show the fit of the line on the graph as well. I am using ggplot2 for other graphics in what I am working on, so even though this would be a fairly easy thing to do in Excel, I would prefer to do it in R to keep my look and feel, and I think ggplot2 is just cooler. Here is a sample
2013 Jan 21
1
Very slow in processing the equation in the scatter plot ggplot
...% italic(x)*","~~italic(r)^2~"="~r2, list(a = format(coef(m)[1], digits = 2), b = format(coef(m)[2], digits = 2), r2 = format(summary(m)$r.squared, digits = 3))) as.character(as.expression(eq)); } p1 <- p1 + geom_text(aes(x = -0.1, y = 0.5, label = lm_eqn(mydata)), parse = TRUE) p1 <- p1+geom_smooth(method="lm",se=FALSE,color="green",formula=y~x,lwd=2) p1 #For multiple layout library(grid) grid.newpage() pushViewport(viewport(layout=grid.layout(2,2))) vplayout <- function(x,y) viewpor...
2017 Jun 25
3
Orden de categorías en gráficos de barras (position = "stack")
...iEPI", "NoEPI")) library(ggplot2) subtit.todos <- "Todos los Espacios (N = 311)." caption <- 'FLACSO - UNICEF - SENAF (2017)' ggplot(tabla.barras, aes(x = Rangos, y = Asistentes, group = Clase2, fill = Clase2)) + geom_col(position = "stack") + geom_text(aes(label = Asistentes), position = position_stack(), vjust = 1, size = 4) + labs(title = "Asistentes por tipo de servicio según tramo de edad." , subtitle = subtit.todos , x = "", y = "Cantidad de asistentes" ) + # , caption = caption) + theme...
2009 Oct 17
2
Putting names on a ggplot
...none", title="Yearly temperatures", axis.text.x = theme_blank(), axis.ticks = theme_blank()) p p <- p + geom_vline(xintercept=month.counts) + ylab("Temperature (C)") + xlab("Daily Temperatures") p # this is where I see the problem. p <- p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) p ============================================================================= DATA =============================================================================...
2017 Jun 24
2
Orden de categorías en gráficos de barras (position = "stack")
...toy perdido por los resultados. subtit.todos <- "Todos los Espacios (N = 311)." caption <- 'FLACSO - UNICEF - SENAF (2017)' ggplot(tabla.barras, aes(x = Rangos, y = Asistentes, fill = Clase)) + # geom_bar(stat = "identity", position = "stack") + geom_text(aes(label = Asistentes), position = position_stack(), vjust = 1, size = 4) + labs(title = "Asistentes por tipo de servicio según tramo de edad." , subtitle = subtit.todos , x = "", y = "Cantidad de asistentes" , caption = caption) +...
2013 Oct 30
1
ggplot2 - how to get rid of bar boarder lines
Hello! I am using ggplot2: ggplot(myplotdata, aes(x=att_levels, y=WTP)) + geom_bar(stat="identity",fill="dark orange",colour="black", alpha = 1,position = "identity") + geom_text(aes(label=WTP),colour="black",size=4,hjust=1.1,position='dodge') + coord_flip() + xlab("") + ylab("") How could I get rid of the border lines on the bars (just leave the fill, but no border)? Thank you! -- Dimi...
2010 Apr 19
2
plotting RR, 95% CI as table and figure in same plot
Hi all-- I am in the process of helping colleagues write up a ms in which we fit zero-inflated Poisson models. I would prefer plotting the rate ratios and 95% CI (as I've found Gelman and others convincing about plotting tables...), but our journals usually like the numbers themselves. Thus, I'm looking at a recent JAMA article in which both numbers and dotplot of RR and 95% CI are
2011 Jul 08
1
Referencing a vector of data labels in ggplot function
...dframe){ withNames <- function(dframe, lineNames, plotName, colors){ p <- ggplot(dframe, aes(date, value, group = factor, color = factor)) p2 <- p + geom_line(size = 1) # + opts(title = plotName) p2 <- p2 + facet_grid(Facet~., scales = 'free') + # p2 <- p2 + geom_text(data = dframe[dframe[,'date'] == '1941-06-16',], # aes(date, value, label = lineNames, vjust = 1)) + scale_colour_manual(values = colors) } finalP <- withNames(data, plines, pTitle, col1) #finalP <- simple(data) [[alternative HTML version deleted]]
2009 Apr 26
7
Bumps chart in R
Hi there, I would like to make a 'bumps chart' like the ones described e.g. here: http://junkcharts.typepad.com/junk_charts/bumps_chart/ Purpose: I'd like to plot the proportion of people in select countries living for less then one USD pr day in 1994 and 2004 respectively. I have already constructed a barplot - but I think a bumps chart would be better # The barplot and data