(aka Geometric objects in r ) A geom is the geometrical object that a plot uses to represent data in r. A ggplot2 geom tells the plot how you want to display your data in R. A geom defines the layout of a ggplot2 layer. People often describe plots by the type of geom that the plot uses. For example, bar charts use bar geoms, line charts use line geoms, boxplots use boxplot geoms, and so on.
Questions tagged [geom]
224 questions
1
vote
1 answer
geom_rect naming a custom legend
I'm creating a line graph showing clinical change over time for a client on the CORE-10. I want to remove the standard legend(which I've managed in the code below) and create a custom legend to show the shaded background area of my graph as:…

mindyeti
- 11
- 2
1
vote
2 answers
How can I avoid connecting points of different groups?
Original data as below:
df<-structure(list(AN = c(2017, 2017, 2017, 2017, 2017, 2017, 2018,
2018, 2018, 2018, 2018, 2018, 2018), MOIJOUR = c("6/6", "6/7",
"6/8", "6/9", "6/10", "6/11", "6/1", "6/2", "6/3", "6/4", "6/5",
"6/6", "6/7"), VPD =…

Chouette
- 153
- 7
1
vote
1 answer
How to avoid overlapp in geom_line
I have a really long and extended code, which I have created with graphs that shows lines overlapping.
Could you please suggest something to disentangle this and make the reproduction clearer? Maybe some other options to modify the size of graph…

12666727b9
- 1,133
- 1
- 8
- 22
1
vote
2 answers
How can I pass variables between ggplot personal functions?
I am trying to create some functions based on ggplot to create custom plots. The creation of functions is very easy and straight forward, but I cannot figure out the way to share information between the functions to help in the plot creation.
Here…

teoten
- 31
- 1
- 6
1
vote
1 answer
How to specify different line types using geom_smooth
I am making a graph for my data and am using the geom_smooth function in ggplot to make them smooth looking line graphs. I would like to make the graphs colorblind friendly, so would like to make the lines either different line types or the points…

mbelanger081
- 13
- 2
1
vote
0 answers
Changing colours for multiple geom_smooth plot
I am plotting a graph with different categories (years) that are represented by different colours. R automatically draw the plot in different blue tones. How can I change the colour of every single year? Do you have any tips? My code…

lxrnax
- 11
- 3
1
vote
3 answers
How do I show only the y axis and hide everything else - including the plot itself and the x axis?
I need to show only the elements of the y axis and nothing else.
name <- c("A", "B", "C", "D", "E")
values <- c(1, 2, 3, 4, 5)
data<-data.frame(name, values)
ggplot()
geom_blank(data=data,…

Apoorva Hungund
- 13
- 4
1
vote
1 answer
Connecting geom_line with dodged points within a point grouping, within a facet_wrap
I can't seem to get geom_path to connect dodged points within a facet_wrap with grouped variables. The path lines remain vertical instead of connecting observations. I want to keep the points dodged as a way to show time trajectory within a…

Chad Kluender
- 11
- 2
1
vote
1 answer
How to assign a specific color to each hexagon plotted by geom_hex
I am trying to summarize a UMAP scatter plot of single cell sequencing data with hexagons. As the goal is to simplify very busy clustering results, I am mixing colors for each bin (=hexagon) according to how many cells of each cluster are in the…

YumTum
- 389
- 1
- 3
- 11
1
vote
0 answers
Line width not changing with geom_pointrange
I am trying to thicken the lines of my plot with geom_pointrange.
ggplot( data, aes(x = xvar, ymin = ymin, y = yvar, ymax = ymax))+
geom_pointrange(shape = 21, size = 1.5, fatten = 0.75,
position = position_dodge(width = 0.5),…

Thornwell
- 11
- 1
1
vote
1 answer
Animate R specific geoms in ggplot/gganimate
I have a dataset where I want to create an animated plot. This plot is going to show progression of the x and y values over time. I can get that working just fine, where this produces a plot with a moving…

rg255
- 4,119
- 3
- 22
- 40
1
vote
1 answer
How change color after certain intervals in ggplot2?
I have following data:
dput(data)
I used following code to generate the plot:
p <- ggplot(data, aes(Zscore, ID))
p + geom_point(aes(colour=pval, size=Hit)) +
scale_color_gradientn(colours=rainbow(4), limits=c(0, 1)) +
…
user2110417
1
vote
3 answers
arrows pointing wrong direction in ggplot2 dumbbell chart
I am trying to create a dumbbell chart comparing baseline to endline values along several metrics and I am so close to having it just how I want it. I start with this data:
> dput(mydata)
structure(list(category = c("food security", "food security",…

bricevk
- 197
- 8
1
vote
1 answer
Problem using scale_size in R from library ggplot2
I am working with the library gapminder and I have generated the following graph to show the relationship between life expentancy, continent and gdp
library(gapminder)
library(dplyr)
library(ggplot2)
df <-gapminder
ggplot(db1 %>%…

slow_learner
- 337
- 1
- 2
- 15
1
vote
0 answers
missing lines when running geom_line function
I am new to R. I am working with a dataseries and want to plot multiple lines on a series where x=midpoint using ggplot. If I am working with data that contains NA values, I understand I should use na.rm=T. I know this kind of data is really…

Johanna Lisa Bosch
- 11
- 1