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
3
votes
2 answers

geom_text on only top part of stacked bar plot

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",…
jjankowiak
  • 3,010
  • 6
  • 28
  • 45
3
votes
1 answer

geom_text() size definitions in ggplot2

I'm trying to vary the size of a geom_text() layer in a ggplot so that the labels are always narrower than a given range. The ranges are defined in the data, but what I don't know is how to scale the label to be narrower than that, without a ton of…
MDe
  • 2,478
  • 3
  • 22
  • 27
2
votes
1 answer

ggplot line plot: is there a way to depict the data points under or over the line plot depending on what looks better?

I wanted to create a line plot based on the data MIA_YEAR. It already looks quite good but I want to move those data points under the plot that (almost) touch the line. Or in mathematial terms: If the slope increases the data points should be under…
blubdidub
  • 23
  • 4
2
votes
3 answers

Show individual bar count label in grouped bar plot

I am trying to plot Male and Female in different Age Groups. I am trying to show the individual Male and Female Count in their respective bars/colours but the graphs shows the total count value in the AgeGroup. How I am going to show/label the…
Usman YousafZai
  • 1,088
  • 4
  • 18
  • 44
2
votes
2 answers

How to remove select labels in ggplot geom_bar plot and center these labels?

Is it possible to remove certain/specific labels from geom_bar ggplot (geom_text) for repeated values and center this value on the plot/bars? My data: structure(list(prey_name = c("Amphipod", "Byths", "Chiro.Adult", "Chiro.Larvae", "Chiro.Pupae",…
FishyFishies
  • 301
  • 3
  • 14
2
votes
0 answers

How to keep geom_text() from getting cut off when it is below the plot?

I'm adding a geom_text() object underneath my plot to give more information about my columns. It has multiple line breaks because, in my actual dataset, I have many columns, so unless I go down lower, the text overlaps. How do I keep my geom_text()…
J.Sabree
  • 2,280
  • 19
  • 48
2
votes
1 answer

How to align the labels to the middle / center in a donut chart

I'm using geom_textpath to add labels to a double donut chart but the labels are not aligned to the middle. How can I align the labels in the middle or the center of each segment? library(magrittr) library(ggplot2) library(geomtextpath) pie_data <-…
anderwyang
  • 1,801
  • 4
  • 18
2
votes
0 answers

Add counts to stacked bar plot with data from 2 data frames

There are several posts similar to this, but I haven't been able to find the right solution for what is probably a simple problem. I am trying to produce a stacked bar plot with counts for both stacks, but the data is in two data frames. This may…
Doda
  • 285
  • 1
  • 9
2
votes
3 answers

How to map geom_text color to a variable

For a bar graph, I want to stack the bar components vertically in a custom order.  In the example below, the variable that should control the stacking order is “mechanism.”  The intended stacking order is neither alphabetical order nor the order in…
InColorado
  • 308
  • 2
  • 12
2
votes
2 answers

Altering facet_grid() height only for one facet (row) is it possible?

I'm trying to improve a simple but important detail in my facet_grid graphic. I played with scale and space parameteres of facet_grid() function. But I would like to increase the height only for the bottom facet in order to be possible to read the…
MagíBC
  • 77
  • 6
2
votes
1 answer

how to assign text to ggplot with a condition when y axis is not numeric in r

I want to annotate a percentage number of missing values for each variable that actually has any missing values somewhere above the corresponding variable blue line. I can add a text using geom_text but I have difficulty with how to select those…
Mathica
  • 1,241
  • 1
  • 5
  • 17
2
votes
2 answers

ggplot geom_text is messing up text order when using R mathematical notation

I am trying to label points in ggplot using geom_text. I would like to use R mathematical notation for the labelling. For example, a point at the x-coordinate 0.5 should have the label 1/2=0.5, where 1/2 is written as a fraction. I have been trying…
Lukas D. Sauer
  • 355
  • 2
  • 11
2
votes
1 answer

How to add a frequency or number on scalebar of stacked barplot using geom_text?

I'm a newbie for using Rstudio, so I've some problems I want to ask. I want to make my scalebar for species composition in 10 sites, and add the number inside the scalebar. The result like this. I want to put the frequency number of species…
2
votes
2 answers

After placing text independently in each panel using facet_wrap() , how to change text color in R?

Here is a data Genotype<- rep(c("CV1","CV2"),each=3) treatment<-rep(c("T1","T2","T3"),2) RATIO<- c(0.8,0.7,0.9,1.1,1.0,0.8) DataA<- data.frame(Genotype,treatment,RATIO) and this is a graph using facet_wrap() A_labels <- data.frame(Genotype=c("CV1",…
Jin.w.Kim
  • 599
  • 1
  • 4
  • 15
2
votes
1 answer

In R ggplot2 , 'vjust' and 'nudge_y' can adjust text position for vertical axis. What is the difference of the two parameters?

In R ggplot2 , 'vjust' and 'nudge_y' can adjust text position for the vertical axis. Can anyone tell me the difference of the two parameters? library(tidyverse) plot_data <- data.frame(cagegory=LETTERS[1:5],amount=c(1:5)) plot_data %>%…
anderwyang
  • 1,801
  • 4
  • 18