Questions tagged [geom-text]

`geom_text` is the geometric object description for creating text-labels in a plot in `ggplot2`

geom_text is the geometric object description for creating text-labels in a plot in .

ggplot2 is an actively maintained open-source chart-drawing library for R.

540 questions
2
votes
1 answer

ggplot: Stacked Barplot - geom_text labels messy

I have grouped my data as desired and added up the quantities correctly. Now I want to create a stacked bar plot in in which I would like to display the labels per Unit. The summarized data looks like this: To read it in R: df <-…
fuul
  • 55
  • 4
2
votes
1 answer

Highlight positions without data in facet_wrap ggplot

When facetting barplots in ggplot the x-axis includes all factor levels. However, not all levels may be present in each group. In addition, zero values may be present, so from the barplot alone it is not possible to distinguish between x-axis values…
M.Teich
  • 575
  • 5
  • 22
2
votes
1 answer

label datapoints when using geom_jitter overlaying on a box plot

I'm overlaying data points on a box plot. The problem I'm encountering is when trying to label the data points, the labels are not displayed over the data point. Any help here is appreciated. Thanks df <- data.frame(sno= c(1:10), A =sample(1:1000,…
user1946217
  • 1,733
  • 6
  • 31
  • 40
2
votes
2 answers

position_dodge and nudge_y together

I am trying to add labels (letters) above a barplot using ggplot2 function geom_text. My bars are separated using position=position_dodge() and so I need to apply the same for the new labels. However I would like to use also nudge_y to separate the…
teoten
  • 31
  • 1
  • 6
2
votes
1 answer

How to increase the interval of labels in geom_text?

I am trying to put labels beside some points which are very close to each other on geographic coordinate. Of course, the problem is overlapping labels. I have used the following posts for reference: geom_text() with overlapping labels avoid…
2
votes
1 answer

Label stacked bar plot with ggplot2

Im tring to plot stacked bar plot, and label each bar with value I calculated. I have vector of values for eah bar. If I use the vector as is I get the warning " Error: Aesthetics must be either length 1 or the same as the data (156): label", so I…
Rachel
  • 41
  • 1
  • 4
2
votes
3 answers

ground geom_text to x axis (e.g. y =0)

I have a graph made in ggplot that looks like this: I wish to have the numeric labels at each of the bars to be grounded/glued to the x axis where y <= 0. This is the code to generate the graph as such: ggplot(data=df) + geom_bar(aes(x=row,…
Momchill
  • 417
  • 6
  • 15
2
votes
1 answer

How to label geom_bar(position = 'fill') using geom_text()

after quite some time searching through SO, I did not find an example that solved my question: How to label geom_bar(position = 'fill') using geom_text()? mydf = data.frame( 'sample' = sample(x = LETTERS[1:3], size = 111,replace = T), 'category'…
bud.dugong
  • 689
  • 7
  • 16
2
votes
1 answer

R ggplot geom_text wipes out background--bug?

I found an issue with ggplot2::geom_text() when I attempt to highlight my data with labels. My MWE illustrates the situation. After I define the plot I add the theme() from phase#1 which colors the panel and plot backgrounds. The red/green is for…
user50506
  • 181
  • 1
  • 7
2
votes
1 answer

Labels are out of order (ggplot2)

When I add labels to my plot, they are in the wrong order. I want to rearrange the LABELS, not the bars themselves. Sample code: df = data.frame(A = c("Apples", "Apples", "Apples", "Apples", "Apples", "Apples", "Oranges",…
2
votes
1 answer

How to vary the length of text in geom_text in R ggplot?

I'm plotting some text using geom_label in ggplot in R but I can't figure out how to vary the size of text based on a variable. Note that by "size" I do not mean the width of the text but its length. Consider the following dummy data and the figure…
Siddharth Vashishtha
  • 1,090
  • 2
  • 9
  • 15
2
votes
1 answer

Coloring and Labeling points in geom_point

I am trying to create a polar chart with two levels as similar to: However I am having a bit of difficulty with coloring the points, then coloring the labels without losing the color on the original points. I do not know if I should ask my…
Jack Armstrong
  • 1,182
  • 4
  • 26
  • 59
2
votes
1 answer

How to align geom_text labels above dodged geom_col

I can't seem to find a way to get the text labels on this (dodged) geom_col to line up according to their respective columns. I have tried numerous suggestions solutions on SO and other sites, and this is the closest I could get: How do I fix…
Mus
  • 7,290
  • 24
  • 86
  • 130
2
votes
2 answers

ggplot2: Add two number of observation in each stacked graph

I have a df as it follows: fruit <- data.frame(Sample=1:100, Fruit=c(rep("Apple", 10), rep("Strawberry", 25), rep("Grape", 20), rep("Watermelon", 15), rep("Lime", 11), rep("Blueberry", 10), rep("Plum", 9)), …
guidebortoli
  • 659
  • 3
  • 8
  • 16
2
votes
1 answer

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

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 <-…
Richard J. Acton
  • 885
  • 4
  • 17