601 questions
0
votes
1
answer
35
views
Adding geom_text in patchwork with shared y-axis and both positive and negative values
I have a patchwork plot consisting of a total of four plots. The procedure I’m asking about is mainly relevant for two of them, though I believe it can be applied to both. These two plots share a ...
0
votes
2
answers
78
views
Positioning of geom_text with negative stacked geom_bar
I have a ggplot2 plot with both positive and negative geom_bar values. For the geom_bar that shows the negative values, I’m having an issue where the position of geom_text is not displayed correctly. ...
1
vote
1
answer
90
views
Positioning geom_text in ggplot coord_polar chart
I am building a pie chart in ggplot using geom_bar and coord_polar and having problems with positionning the labels with geom_text. Ggplot seams to change the order of the classes and put the labels ...
2
votes
1
answer
90
views
ggplot2 geom_textpath spiral with datetime axis
I'm trying to replicate the spiral example for geom_textpath() shown at the top here: https://allancameron.github.io/geomtextpath/
My y-axis is numeric, so that part works out fine, but my x-axis is a ...
0
votes
1
answer
69
views
add geom_label and geom_density to barplot distribution
I'm working on a plot showing the length distribution of some events in the human genome. I'm pretty OK with the end result but wish to add a geom_label for the highest count reporting the ...
3
votes
3
answers
199
views
How to plot text only, without any margin, in a tiff file?
I want to build a tiff file with text only and no margins around the text, using R.
I tried :
library(ggplot2)
plt <- ggplot() +
geom_text(aes(x=0,y=0,label="test")) +
theme_void()
...
1
vote
1
answer
187
views
Changing font to Arial (Liberation Sans) of ggplot2/geom_text
I've read this solution:
But it is Windows specific so it didn't work for me.
Is there another solution?
I've loaded my font like this:
install.packages("showtext")
library(showtext)
...
1
vote
1
answer
133
views
ggrepel does not work in tertiary diagram
I am creating a tertiary plot in a shiny app and the points are in different parts of the plot depending on the selected sites. The labels need to repel when points are overlapping or land on the axis....
3
votes
0
answers
79
views
ggplot2: geom_text getting behind my x label in graph
I get this R ggplot2 working graph:
library("xkcd")
library("extrafont")
library("ggplot2")
library("gridExtra")
X <- c(0,20)
prova_A <- 0 + 5*X
...
-1
votes
1
answer
1k
views
Labeling specific points on volcano plot
I am having trouble showing the points of interest on my ggplot. When I select for my genes in geom_label_repel() i only get 3 that appear when i know that there are 57 that show up in the list.
fig1. ...
3
votes
1
answer
119
views
Set labels on top of horizontal stacked barplot in ggplot2
I have a dummy dataset:
tmp <- structure(list(order = c("John", "John", "John", "Ross", "Ross",
"Ross", "John", "John&...
0
votes
1
answer
126
views
What does annotate() shift over my geom_text() in ggplot2 when using rich text?
I have 2 plots that I'm joining together. The top shows the raw data and the second is a subjective rating. The issue is that when I try to have a label using annotate() with rich text explaining what ...
1
vote
0
answers
46
views
Add datapoint labels to ggplot2 with giscoR map
I have prepared a map of the UK using giscoR and have successfully added location points to the map using latitude and longitude and ggplot2. I now want to add labels to these points but when I ...
2
votes
1
answer
94
views
Add geom_text with x bar and round values
I have a 6-facet ggplot2 bar chart. I want each facet to be annotated with its respective mean value. Like this:
x̄ = 0.25
So I have been trying:
geom_text (data = averages, inherit.aes = FALSE,
...
0
votes
1
answer
136
views
ggalluvial plot move and round flow percentages
I am adding flow percentages in my ggalluvial plot based on an existing StackOverflow case (how to calculate percentages in geom_flow() based on variable size and not stratum size) which works fine.
...
1
vote
1
answer
71
views
In pacakage `GGally` `ggparcoord`, I want add labels to the plot, but `geom_text` failed
In pacakage GGally ggparcoord, I want add labels to the plot, but geom_text failed, how to fix it ? Thanks!
library(GGally)
library(tidyverse)
data <- iris
Create basic plot plot_basic
...
0
votes
1
answer
65
views
How do you add both data frame values and math operators to geom_text in R? [closed]
I'm attempting to use geom_text to create a label 'Ankle Absorption W = -0.52 - 0.13 x Hop Height'. My understanding is that I need to use %*% within expression() to output the x sign. The numbers are ...
1
vote
1
answer
184
views
In r: geom_text label shifts horizontal position between dodged bars
In the following ggplot in r, I would like my "n" labels to be aligned with the left side of each bar — as they are on the pink bars but not on the blue bars. Somehow, the dodging is not ...
1
vote
3
answers
61
views
Using geom_text or geom_label inside geom_bar
I am plotting the publication of scientific papers on a specific research topic on a timeline. I would like to add author and year to the corresponding rectangles using the "label" variable.
...
1
vote
1
answer
34
views
How to adjust position of geom_text() with counts of zero for bars of barplot with geom_bar() in different groups?
I'm trying to add values at the top of my bars of a barchart with two groups. It works fine for values above zero.
But I have also levels where there were no counts, so bars with the hight of 0. Then ...
0
votes
1
answer
69
views
Is there a way in ggplot2 to fit several columns of text, minimising the space between them?
I'm trying to use RStudio and ggplot2.
I have a list of studies, some information about their data and another couple of columns of numbers.
What I would like is a plot where I could fix the size of ...
0
votes
1
answer
61
views
How to adjust the symbols overlayed over a bar plot?
I have created a divergent bar plot, and after the plot is created I want to add several symbols in order to indicate some information about then as a footnote. I provide the code to create the object ...
-1
votes
1
answer
35
views
How to get geom bar percentages to reflect within-group percentages rather than the overall percentage [closed]
I have a dataset in R that looks like this:
With the following code I get the graph below:
ggplot(subset(f,!is.na(d)),aes(x=d,y=(..count..)/sum(..count..),fill=forcats::fct_rev(e))) +
geom_bar(...
0
votes
1
answer
70
views
ggplot2 faceting and adding unique labels for each facet in a for loop in R
I am trying to add a unique label to each faceted panel in my plots. Below is the code which I annotated and will describe in detail below:
ebird <- left_join(ebird, cor,
by = ...
0
votes
1
answer
44
views
How to swap labels on stacked bar graph using geom_text?
When producing a stacked bar graph that has different color by facet variable and bar fill variable, I would like to add the number/count by each color. I am using the geom_text function by it seems ...
0
votes
0
answers
25
views
Why does there occur an a in my legend color boxes? (pie charts using coord_polar() and facet_wrap() )
I've created pie charts using geom_bar() and coord_polar(). Finally, I've got my graph as I wanted it besides of this:
There occurs an letter (a small "a") in my legend boxes and I don't ...
0
votes
1
answer
52
views
Overlay text when using geom_text and facet_wrap in R
I'm having some trouble with the geom_text combined in facet_wrap function in RStudio.
I wanted to insert the R^2 of each function in each graph created with the ggplot2 library.
I've summyrised the R^...
0
votes
1
answer
48
views
In `ggfittext::geom_fit_text` , it seems can't use `vjust`
In ggfittext::geom_fit_text , it seems can't use vjust . Below amount and value are override . Anyone can help on this ? Thanks
library(tidyverse)
library(ggfittext)
diamonds %>% group_by(color,...
0
votes
1
answer
49
views
ggplot: Avoid geom_text() being placed over each other
I have the following common scenario: I have climate data observations and predicitons for a certain point. To evaluate the model performance the data gets plotted in a line plot and the metrics ...
0
votes
1
answer
149
views
How do you format the text displayed by geom_text_contour?
MWE:
library(metR)
heat_palette = c("darkred", "red", "yellow", "#00A600", "darkgreen")
heatmap_of_percentage <- function(percent) {
# display &...
0
votes
0
answers
34
views
I want the x-axis label to set the color according to the ONTOLOGY classification, so I use geom_text() to add the label
I want the x-axis label to set the color according to the ONTOLOGY classification, but axis.text cannot complete such an operation, so I hide the original x-axis label and use geom_text() to add the ...
1
vote
1
answer
181
views
Adding superscript and minus signs to data and axis labels in ggplot2
I'm trying to make a forest plot using some data:
dt <- data.frame(outcome = c("A", "B", "C", "D"),
beta = c(-0.007, -0.008, -0.009, -0.009)...
0
votes
2
answers
69
views
align all geom_text above individual columns
I have this app, that should show the p-values stars above the columns or confidence intervals if selected. It works for one category, not another (only two of the four categories apply). How can I ...
2
votes
2
answers
295
views
Why is it so slow to add a geom_text to ggplot2?
I have found a problem when plotting hex graphs using ggplot2. When I use geom_text to add text to the graph, it takes a very long time!
I made a minimal, self-contained, reproducible example and you ...
1
vote
1
answer
236
views
R ggplot geom_text_repel: duplicate colliding label problem
This question uses the public data and code from another question
I am trying to add labels to my map. When I use geom_text, each label correctly appears once but collided (right side). To avoid ...
4
votes
2
answers
176
views
Why do some of the geom_text labels flipped when added on a dodged geom_col?
I have the following dataframe df:
df <- structure(list(ID = c(1, 1, 2, 2, 3, 3, 4, 4), Group = c("A",
"B", "A", "B", "A", "B", "B&...
2
votes
1
answer
183
views
ggplot R, hjust='inward' makes label neither fully inside nor outside
The graphic generated by the code below is updated on a regular basis, and it has been working ok every time, but with the addition of a new data for "Japan", the label is sitting neither ...
3
votes
1
answer
57
views
Numbers in parentheses are not centered in ggplot
Numbers are top justified with parentheses in geom_label_repel() (Example with code below). The same behavior occurs when using geom_label(). How can I get the numbers in the labels to be in the ...
1
vote
1
answer
41
views
displaying single value from a different dataframe in ggplot [duplicate]
I'm trying to display a single value in my ggplot, but from a different data frame than the rest of the plot data. Basically, I just want to insert "d = [value from second dataframe]" in a ...
2
votes
1
answer
413
views
Prevent overlapping of labels in stacked bar chat (geom_text)
I am trying to create a stacked bar chart with percentages in R. The problem that I have is that some of the labels are overlapping in the bar (see the two 3%-labels in the bar at the bottom position):...
1
vote
1
answer
82
views
How to align geom_text() in a facetted and flipped stacked bar chart
Here is my fake data:
dat1 <- structure(list(A_B = c("A", "B", "A", "B", "A", "B", "A", "B",
"A", "B&...
1
vote
1
answer
51
views
Geom_text above grouped geom_bar when theres negative values present
Consider this data:
# A tibble: 15 x 3
group variable value
<int> <fct> <int>
1 1 1 0
2 1 2 0
3 1 3 -2
4 2 1 1
...
1
vote
1
answer
205
views
How do I adjust the position of geom_text over geom_bar columns in ggplot?
I am attempting to make a bar graph in ggplot2 but when I add labels, they cluster over one middle bar rather than sitting on the bar the value itself represents.
The code I am using:
synch<-data....
1
vote
2
answers
78
views
Make more room for lables in ggplot in r
Is there a way to have this plot squeezed a little so labels of extreme cases (A and G) have could show up completely.
code:
x <- LETTERS[1:11]
y <- c(9, 4, 6, 8, 5, 7, -9, -4, -6, -8, -5)
z &...
-1
votes
1
answer
59
views
Why are all the bars in my boxplot lumped together?
I tried to create boxplot for each date. But they were not distributed by date. Instead, the data for all dates were gathered together.
Here is the original data:
df<-structure(list(traitement = c(&...
0
votes
1
answer
242
views
Conditional labeling and manual manipulation of labels in geom_text in R
Could anyone help me figure out how to:
Use geom_text to show labels only for those down and up categories (how to remove stable labels)
How to manually change negative labels to positive ones (erase ...
3
votes
2
answers
192
views
How to position labels correctly in a grouped beeswarm plot
Here is a reproducible example:
library(ggplot2)
library(ggbeeswarm)
ggplot(mtcars, aes(x = factor(am), y = mpg, color = factor(am))) +
geom_quasirandom(pch = 15, size= 6, alpha=0.7) +
geom_text(...
0
votes
1
answer
46
views
Customizing geom_text better
For one of the past weeks' TidyTuesday challenges, I tried to plot the US House Elections results. Here is the code;
library(tidyverse)
library(showtext)
library(showtextdb)
library(geofacet)
library(...
1
vote
1
answer
270
views
How to add multiple labels to faceted ggplot outside of the plot?
I use facet_rep_grid to visualize different variables over the same x-axis. Now I would like to label the top left of each facet with "A", "B", "C" etc.
what i have looks ...
0
votes
1
answer
92
views
ggplot2 - having trouble with geom_text with facet_wrap
I created a decent-looking figure in ggplot...
pollinators_1 <- ggplot(data = pollinator_counts_hybrids, aes(x = pollinator.species, y = n, fill = taxa.visited)) +
geom_bar(stat = '...