(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
0 answers
How do I change the geom lines between group categories across different timepoints (ggplot)?
Just started learning ggplot and I'm trying to change my groups to show different geom lines (i.e. one dashed, one smooth/straight line). Below is a mock of my code and how my plot currently looks:
ggplot(longdat,aes(visitnum,score, colour=Groups))…

Monarch
- 135
- 6
1
vote
1 answer
R/ggplot2: Issue with geom_line connecting 2 scatterplot datasets instead of using separate lines
I have 2 simple scatterplot datasets that I combined, and the resulting graph (in ggplot2) is exactly what I want except for the lines connecting the data. I'm trying to make it so there are two separate dashed lines with two different colors, but…

Rachel Davitt
- 61
- 3
1
vote
0 answers
My plot is too thin after adding the significance to a plot
I want to add the level of significance my plots with facet_nested, I initially used an old code but it doesn't seem to be working this time around. In the end, I want a plot like the one below.
My plots are very thin and I am wondering if there is…

Reuben Newton Addison
- 349
- 1
- 10
1
vote
1 answer
Fixing Fill in geom_hex
I'm struggling to get geom_hex to fill with a certain variable. My goal is to get geom_hex to fill with the variable xRV, with lower values being red and higher values being blue, but as things stand all I get is gray hexagons.
Here's the df:
IVB <-…

npLA5
- 13
- 3
1
vote
2 answers
Produce smooth error bar around multiple line graph using standard error in data frame
Produce smooth error bar around multiple line graph using standard error available in the data frame. I already have the stadard error in the data frame so I could use data +/- se.
Produce smooth error bar around multiple line graph using standard…

Reuben Newton Addison
- 349
- 1
- 10
1
vote
0 answers
Why does geom_smooth throw an error for all plots in a chart if one of the plots has two or less values?
I have data In three flavours and want to show it as three different plots in a chart. I also want to use geom_smooth on the plots. When one of the flavours of data has less than seven values, geom_smooth can not be rendered for that plot. This is…

chilifan
- 157
- 1
- 12
1
vote
1 answer
Sort values in dumbbell plot horizontal bar in R
I am trying to sort my plot values on the vertical axis in a similar order in both facets. For instance in the plot attached under visible the order for the conditions are ("IPS", "CTR", and "CEN"), I want the same arrangement for the facet -…

Reuben Newton Addison
- 349
- 1
- 10
1
vote
1 answer
geom_smooth no regression line
I have the following data and I am trying to make a scatter plot with regression line using ggplot2 package in R
Here is my code:
df <- read.table(text = "tumor density fraction
A 2.31 0.224
B 2.76 0.042
C 1.51 0.039
D 1.48 …

user3138373
- 519
- 1
- 6
- 18
1
vote
1 answer
Multi- X-Axis in R
I'm trying to create a plot that looks like the image below, but I'm really struggling when it comes to the multiple x-axis. Any help would be appreciated. Sample code for the figure provided.
Sample Figure:
df <- data.frame(Time=c(" ","Phase…

Matt Landry
- 13
- 3
1
vote
1 answer
Geom ribbon, shading area under the curve above a specific threshold?
I can't seem to shade the areas under the curve, the geom_ribbon seems to be already shading the correct area, but I want to place the shaded areas underneath the curves such that when the y-values are above 120, the region under the curve is shaded…

CodingMemes
- 25
- 4
1
vote
1 answer
Creating a second legend with ggplot?
I created the following plot using ggplot:
y1 <- runif(20,-2,7)
y2 <- c(-0.30306664,0.14744265 , 0.43857131 ,-0.04536794 ,-1.41432016,0.51887010 , 6.34925495 , 2.82511601 , 2.84251791, 4.05300569,-2.34208042, -0.29278747 , 0.49661933 ,…

Joe94
- 91
- 7
1
vote
1 answer
How to have consistent shading of geom_rect when using facet_grid?
Here is the data I am working with:
df= structure(list(effect = c(-0.183660494380325, -0.286711283030125,
0.144420824373155, 0.107958002095135, -0.236028784063033, -0.160120624560128,
-0.241734940173219, -0.301094909534684, 0.080319901278758,…

yuliaUU
- 1,581
- 2
- 12
- 33
1
vote
1 answer
Strange behavior (duplication of variable) in my dumbbell plot when trying to add text to plot
I am finding a hard time understanding why my plot is showing this strange behavior. I was adding a text to my dumbbell plot but when I try that I get a warning ("Scale for 'x' is already present. Adding another scale for 'x', which will replace the…

Reuben Newton Addison
- 349
- 1
- 10
1
vote
0 answers
Adding north arrow and scalebar to ggmap plot
I am having issues getting a north arrow and scale bar on my plot.
I built the plot using ggmap and I am using the ggsn package to get a north arrow/scalebar but I am getting the following error:
"Coordinate system already present. Adding new…

KC Ray
- 77
- 9
1
vote
0 answers
facet_wrap() is not plotting by crashing with geom_rect()
I am trying to plot the growth of my plants. But I want to highlight the different stages with a geom_rect() of different colors. My code does it when it is all together, but when dividing them with facet_wrap() I get an aes() error, can somebody…

Cesar Figueroa Lopez
- 11
- 1