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

R: ggplot annotate geom_text with position_dodge and facets

I have an R dataframe data (made with dplyr) that I'm trying to plot with ggplot(): require(dplyr) data <- structure(list(gGroup = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c("MC", "R", "UC"), class = "factor"), …
Jasper
  • 555
  • 2
  • 12
0
votes
2 answers

geom text for facets is not positioned at visually pleasing location

Data > dput(my.precious) structure(list(Vehicle.ID2 = c("2351.2360", "503.496", "2508.2498", "2256.2243", "952.946", "2327.2315", "683.682", "880.866", "347.342", "115.116", "2239.2229", "1680.1675", "1044.1029", "323.321", "2354.2337",…
umair durrani
  • 5,597
  • 8
  • 45
  • 85
0
votes
1 answer

How to write after decimal zero in ggplot (geom_text)

I am wondering how i can put after decimal zero in the faceted ggplot plot. Following picture make it more clear. I would like to write r-squared =0.61 and 0.30 in two facets of ggplot using geom_text. It writes 0.61 properly but writes only 0.3 and…
Cirrus
  • 638
  • 3
  • 13
  • 26
0
votes
1 answer

geom_text and grouping

Here is a piece of ggplot2 code plotting a set of 4 densities from samples: library('reshape') library('ggplot2') data <- matrix(0,5,100) for(i in seq(1,5,1)){ data[i,] <- rnorm(100,i,1) } df <- data.frame(melt(data)) g <- ggplot(data=df,…
peuhp
-1
votes
1 answer

Can't get geom_text to appear in ggalluvial

I have been using code that is verbatim to that in: https://www.r-bloggers.com/2022/10/how-to-create-a-ggalluvial-plot-in-r/ in order to produce an alluvial plot. While I can get the plot to appear: My Code: #install.packages("ggalluvial") …
-1
votes
1 answer

R ggplot- line labels to right of plot without overlapping

To preface, I'm relatively new to R and trying to replicate a previous user's inquiry found here: Stackoverflow question. Instead of the data being in days, and looking only at more recent set of dates, I want to include all points of time, in…
a_swoosh
  • 23
  • 7
-1
votes
1 answer

Wrapping geom_text / geom_label on ggplot (R)

I am trying to find a way to wrap geom_text/geom_label on a scatterplot (ggplot). I have seen ways this can be done manually inputting the co-ordinates - but i will have 10-20 variables, so this will not be possible. I have a data frame that looks…
Henry
  • 3
  • 4
-1
votes
1 answer

Displaying the labels in a box at the top right-hand corner of the figure

As shown in the plot below, the state names are sometimes far from the line. One option to consider is not to put the labels next to the lines, but instead to include them in a box at the top right-hand corner of the figure. How can I do this? Here…
Nader Mehri
  • 514
  • 1
  • 5
  • 21
-1
votes
2 answers

Ploting in ggplot2 with geom_line() with label

I'm trying to plot this dataset with ggplot2, putting the name of each country in each line geom_line() and with the x axis (Year) and the y axis (with the relevant data from each country). The DataSet to Edit This is what I have so far. I wanted to…
Sebastian
  • 3
  • 2
-1
votes
1 answer

How to add y axis values on the bar plot in r using ggplot and geom_bar()?

Hi I have been trying to summarize my data set by sum of a particular column and using ggplot and geom_bar() directly to do so instead of using tidyvers and dplyr libraries. I read about weight aesthetic and that it can help plotting bar graph as…
-1
votes
1 answer

"Error in eval(expr, envir, enclos) : object 'y' not found" and "Removed 1 rows containing missing values (geom_text)"

It says that the error is in the "library(ggplot2)" line and I don't know how to fix it. Here's the code I was using: library(ggplot2) library('remotes') remotes::install_github("GuangchuangYu/nCov2019", dependencies =…
-1
votes
4 answers

ggplot2: show relative % in a stacked barplot per group

I'm trying to plot a basic bar chart per group. As values are pretty big, I want to show for each bar (i.e. group) the % of each group within the bar. I managed to show percentage of the total, but this is not what I'm expecting : in each bar, I…
Flecflec
  • 233
  • 3
  • 9
-2
votes
2 answers

geom_text making label appear on plot doesn't work

I am trying to make the values of the column "activité en valeur" of my dataframe appear above my bars in geom_bar, yet it doesn't work as i get the following message of error "Aesthetics must be either length 1 or the same as the data (11): label".…
-2
votes
1 answer

Adding values to geom_col messes up the whole plot

When I add the geom_text to the geom_bar, the whole plot gets messed up. > x # A tibble: 3 x 6 # Groups: Jahr, Monat, Bez [3] Jahr Bez TWh Total Monat MonatsEAnteil 1…
Beat
  • 1
  • 1
-3
votes
1 answer

Avoid overlapping text labels using ggplot2::coord_polar

I have a plot with points on a polar coordinate system. Each point has an associated label, which should be shown around the plot at the given angle. This can be achieved either using axis.text or geom_text; I have used geom_text here.…
simoncolumbus
  • 526
  • 1
  • 8
  • 23
1 2 3
35
36