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

Superscript and subscript points in ggplot2

I would like to add sub/superscript to some letters/characters in a ggplot2 point plot. I know how to do this in the axes, but in this case, because they are special characters, I define a character vector before plotting: IPA=(c("ph", "th", "kh",…
MeC
  • 463
  • 3
  • 17
2
votes
1 answer

accurate placement of geom_text label on a month axis

How to adjust the geom_text so that it is visible properly? data <- read.table(text = " months preMonth postMonth preOnc postOnc 1 2017-10-19 958 543 242 657 2 2017-11-19 958 177 242 1023 3 2017-12-19 958…
Prradep
  • 5,506
  • 5
  • 43
  • 84
2
votes
2 answers

conditional size and face in geom_text_repel

I am working on a fairly large scatter plot, and I am using ggrepel as a method to avoid overlapping labels. However, I need to distinguish between some data points, and the idea would be to also rely on size and face to do so. I post the…
Erdne Htábrob
  • 819
  • 11
  • 29
2
votes
2 answers

R: Adding number of observation on the barplot with geom_text

I know that this question has been asked very often, but I tried all the method I found and none of them seems to work.. This is my current data. df <- data.frame(ID = c(1,2,3,4), Type = c("A","B","A","B"), Score1 = c(10,20,30,40), Score2 =…
Maru
  • 163
  • 1
  • 2
  • 10
2
votes
1 answer

Position ggplot text in each corner with facet

I have a data frame with 10 values in each of the 5 kinds and have 2 types. df <- data.frame(x2=rnorm(100),y2=rnorm(100), type = c(rep("type a", 50), rep("type b", 50)), kind = rep(LETTERS[1:5],10)) I want to print the labels of percent of values…
Rashedul Islam
  • 879
  • 1
  • 10
  • 23
2
votes
1 answer

ggplot2: adjust geom_text() position in facet_wrap() with different y axis scales

I got this plot Using this script ggplot(df, aes(x=site_id, y=value)) + geom_bar(stat ="identity", width = 0.8, fill = "lightgreen")+ facet_wrap(~var, scales ="free_y")+ theme_bw()+ labs(x= " ")+ …
shiny
  • 3,380
  • 9
  • 42
  • 79
2
votes
1 answer

How to give multiple conditions in geom_Text

I have the following plot of a stock's price in response to time on different days. Currently, using geom_text I'm able to label the points of interest where the Y value deviates from 0 by a significant positive. However, I also wish to label the…
shoestringfries
  • 279
  • 4
  • 18
2
votes
1 answer

ggplot2: add RMSE values of two models to each facet

Using this data.frame DATA #import_data df <- read.csv(url("https://www.dropbox.com/s/1fdi26qy4ozs4xq/df_RMSE.csv?raw=1")) and this script library(ggplot2) ggplot(df, aes( measured, simulated, col = indep_cumulative))+ geom_point()+ …
shiny
  • 3,380
  • 9
  • 42
  • 79
2
votes
1 answer

Conditional text color in geom_text, scale_color_manual

Here I set colorRed to TRUE so the text is red. But when I set it to FALSE, the color is still red. How to make the text color conditional on the value of colorRed? library(ggplot2) ann_text = data.frame(x = 1.5, y = max(mtcars$mpg), LABEL =…
John
  • 1,779
  • 3
  • 25
  • 53
2
votes
1 answer

How to align geom_text according to clock values

Hopefully someone can help me with this problem. I´ve tried several solutions with no success. I want to replicate following figure #1. Therefor I´ve added the variable clock (with values from 1 to 12) to my data frame to use it as parameter for…
Kaizen502
  • 35
  • 1
  • 6
2
votes
1 answer

How to add labels to points conditionally in a city map using ggmap

I was trying to label points using name on the map conditionally for a city. Data name |s Latitude |s Longitude |s Frequency Pelham Bay Park | 40.865556 | -73.808333 | 32 Greenbelt | 40.58846 | -74.139073 | 10 Van Cortlandt Park |…
bob jones
  • 23
  • 1
  • 5
2
votes
1 answer

Error: Aesthetics must be either length 1 or the same as the data (4)

I am working with ggmap. the goal is to plot coordinate points on the map and label the points with their names. I have data frame with name, longitude and latitude. The data looks like: df <- structure(list(Station.Area = c("Balbriggan",…
Sharvil Raval
  • 29
  • 1
  • 1
  • 5
2
votes
2 answers

Using geom_text in a for loop with ggplot2

I want to display a list of text labels on a ggplot graph with the geom_text() function. The positions of those labels are stored in a list. When using the code below, only the second label appears. x <- seq(0, 10, by = 0.1) y <- sin(x) df <-…
Ben
  • 6,321
  • 9
  • 40
  • 76
2
votes
1 answer

ggplot / geom_segment: sorting y-axis labels (factors) according to value of variable

The graph below is a 'pseudo' gantt chart which intends to depict the duration (x-axis in calendar years) of some wars plus number of casualties . i would be grateful if you could help me to solve two issues I am facing. 1) I would like to sort the…
zoowalk
  • 2,018
  • 20
  • 33
2
votes
1 answer

geom_text evaluation using facet_wrap

I need to plot three pie charts using the following data frame: df <- data.frame(id = rep(LETTERS[1:3], each=5), var = rep(letters[1:5], 3), value = c(10, 8, 6, 4, 2)) This code produce the type of chart I…
Michele
  • 8,563
  • 6
  • 45
  • 72