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
4
votes
1 answer

Legend symbols for webdings symbols in ggplot2 graph

I've consulted a number of helpful SO posts to help me place right- and left-facing triangle symbols on my plot. I wanted to indicate the start of data collection, and the end of data collection. The Webdings font has some nice caret symbols that do…
Nova
  • 5,423
  • 2
  • 42
  • 62
4
votes
1 answer

How to pass an expression to a geom_text label in ggplot?

I am attempting to pass an expression with subscript to a single geom_text() label in ggplot. Here is my code right now: my_exp <- expression('my_exp'[s][u][b]) my_data <- data.frame( var_1 = c("a", "b", "c"), var_2 = c(1, 2, 3) …
Reb Gray
  • 87
  • 1
  • 4
4
votes
2 answers

How can I have different geom_text() labels in a faceted, stacked bar graph in R with ggplot?

I am trying to use facet_wrap with stacked bar graphs, and I'd like to have labels on the bars showing the value of each part of the bar. Using the diamonds dataset as an example: My geom_text code works fine when there is only one graph, albeit…
4
votes
1 answer

How do I stop R ggplot from displaying "a" as the symbol in my legend?

Recently I made a plot using ggplot in R. When I add my code for ggplot_label_repel, suddenly the symbols in the legend change from circles into the letter "a". Does this have something to do with wingdings font? How do I fix my legend? I have made…
lizs
  • 55
  • 5
4
votes
1 answer

R ggtree: How to label single tree tip with ggtree similar to labeling nodes with geom_cladelabel

I'm having trouble with labeling single tips in my tree with ggtree. I'm trying to highlight and label nodes from a tree with geom_hilight and geom_cladelabel. This seems to work fine with nodes that have more than 1 tree tip, but when I try to…
Kak Schoen
  • 364
  • 2
  • 18
4
votes
1 answer

Percentages for geom_text in stacked barplot with counts

I want to have a stacked barplot with percentages in it based on counts. I have almost reached what I want but every value in the text is 100% instead of the real percentage ... I think there is one small mistake in my code but I can not find…
TobiSonne
  • 1,044
  • 7
  • 22
4
votes
1 answer

How do I use adjust_text with plotnine?

I am trying to adjust geom_text labels so that they don't overlap. Adjusting the labels using nudge_x, nudge_y and size does not give me a very satisfying result. I came across the adjust_text package but I don't manage to implement it to my code.…
polarpanda
  • 43
  • 5
4
votes
1 answer

How to calculate and plot percentage labels for stacked bar with the total of the bar?

I'am trying in R to plot the percentage labels for each bar in a stacked bar, if you see the first bar, the sum of percentages is 28%, not 100% as i am looking for it. it should be 72%, 14%, 14% for the first bar, for the second bar 11%, 67%, 22%…
Luisa Restrepo
  • 433
  • 4
  • 5
4
votes
2 answers

ggplot2::geom_text font as the rest of graph

I got the following graphs using the code given below: library(ggplot2) library(ggthemes) p <- ggplot(data = mtcars, mapping = aes(x = wt, y = mpg)) + geom_point() + theme_igray() p p + geom_text(mapping = aes(label =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
4
votes
1 answer

R ggplot annotated with atop using three values and bgroup

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…
user971102
  • 3,005
  • 4
  • 30
  • 37
4
votes
2 answers

custom geom text colors in ggplot2 with R

I want to visualize the tennis data using ggplot. So far I am able to visualize the data based on winner/loser data. 2015 Flavia Pennetta 81 2014 Serena Williams 65 2013 Serena Williams 109 2012 Serena Williams 94 2011 Samantha Stosur…
Anish
  • 1,920
  • 11
  • 28
  • 48
4
votes
1 answer

Add axis text above horizontal geom_bars; justify text flush left

I would like to place axis text above the appropriate horizontal bars in a ggplot2 plot. Below is as far as I have gotten, with the plotting code afterwards. The data is at the bottom of this question. My questions, aside from the ever-present…
lawyeR
  • 7,488
  • 5
  • 33
  • 63
4
votes
3 answers

positioning labels on geom_bar

I am trying to create a horizontal bar chart with category labels using ggplot. I have been able to create the plot without hassles, and can put labels on, however I suffer issues with the formatting. Ultimately I would like to have my label within…
Dan
  • 2,625
  • 5
  • 27
  • 42
3
votes
1 answer

Geom_label_repel: How to pull labels toward 4 corners of a scatterplot

I have a set of product scores I want to visualise in a scatter. What I'm trying to do is have the labels pull to the four separate corners of the chart. In reality, I have 30-40 to space which is why I'm using ggrepel for the…
Carl
  • 33
  • 3
3
votes
2 answers

Adding filtered row names as labels in geom_point using geom_text (error on length of the dataset)

I have a dataset and I want to add specific labels (row names in this case) to my ggplot graph. However, when I use filter, an error regarding length of the data frame shows on the console. I would appreciate if anyone could help me to resolve the…
rez
  • 290
  • 2
  • 12