(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
0
votes
1 answer
R plot date data multiple geom_line
Plotting the below data. trying to include the lines per tech, Without using the facetwrap.
Plot both tech and files per enm…

leoin86
- 17
- 5
0
votes
2 answers
Is there a way to add section labels to the x-axis of a plot using ggplot2?
G'day,
I have a bunch of data which can be grouped. I want to display those data in a plot.
Nothing special so far. But i have stumbled over the problem of displaying the data in a way, that signals their grouping. What i want is header for each…

Lenman55
- 27
- 4
0
votes
1 answer
What is the best way to create visually appealing partially overlapping 2D density plots with varying colors and shades in ggplot2?
I want to represent two different 2D distributions using ggplot2. But the two distributions are partially overlapping and I am struggliing to make it look nice.
For example, here is a plot from this code...
ggplot(control_group, aes(x=eTIV,…

Jamie Ward
- 1
- 1
0
votes
0 answers
How to add a rectangle to a ggplot graph with a logged y-axis without changing the y-axis scale
I am trying to add a rectangle to a ggplot graph with a logged y-axis using annotate() or geom_rect(). The rectangle is bounded by two x-axis values (which are dates) and needs span the enitre y-axis. However, whenever I add the rectangle, it…
0
votes
1 answer
How can I draw 2 types of line segments in the same 1 format?
Here is the original code I have:
df<-structure(list(Bloc = c(1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1,
1, 2, 2), Pos_heliaphen = c("Z16", "Z17", "Z30", "Z31", "Z16",
"Z17", "Z30", "Z31", "Z16", "Z17", "Z30", "Z31", "Z16", "Z17",
"Z30", "Z31"),…

Chouette
- 153
- 7
0
votes
1 answer
geom_line not connecting as per y-axis
I want geom_line to connect 0 to 0-2 then 2-5 and 5-10, in the following order and not based on the X-axis data. Except for one point, others are correct. Here is my script.
ggplot(dat_combined, aes(x = mean_delta_13C, y = depth_cm)) +
…

J.M
- 25
- 4
0
votes
1 answer
geom_area plot y value greater than 1 when plotted
all.
I am giving a label to each sentence in an article. I am trying to generate a stacked area plot to show at a specific location, the percentage of a certain label.
The location is calculated as (sentence_index/total_number_of_sentence)
The…

FewKey
- 152
- 9
0
votes
0 answers
Displaying data on secondary axis that are not related in ggplot
I have seen a lot of answers to questions regarding secondary axes but they all seem to be transformations of the data being presented for the primary axis, usually for data that is directly related.
I have two data frames that entirely different…

JackWassik
- 65
- 6
0
votes
0 answers
Convert MULTIPOLYGON string to a MULTIPOLYGON object for graphing in R
I have a data frame with a character column where each observation looks like this:
[1] "MULTIPOLYGON (((-108.80001058777736 37.10000583381149, -108.70001056633824 37.10000584006442, -108.70001055671808 37.00084259698653, -108.80001057814715…
0
votes
0 answers
Problem with aplying the border colour of a shaded rectangle legend
It's a minor issue but one of the rectangles showed in the legend ("Intrusión de polvo sahariano") has its border colour mistaken, instead of orange its border is grey.
This what I've donde. Thanks in advance.
data1 <- timeAverage(Calibración,…
0
votes
0 answers
How do I increase the number of evaluation points in stat_smooth for ggplot2 in R?
I am fitting one of my data using stat_smooth in ggplot. Here is the brief of the code:
library(ggplot2)
my.data <- fread('data.txt',header=T,na.strings=c(""))
my_exp_formula <- y ~ a * exp(b*x)
ggplot(my.data, aes(x=x, y=y, colour=CA, group=CA))…

user3132983
- 65
- 1
- 5
0
votes
1 answer
Issues plotting selected samples from a data frame using ggplot2
I'm attempting to plot selected samples from the larger group of samples I have in a data frame in R.
The data frame is constructed as follows:
round1Counts <- data.frame(
Sample = c(round1[1:20,1], "LowerLimit", "UpperLimit"),
Day =…

murraylf
- 1
0
votes
1 answer
geom_raster: how to interleave Y axis ticks in ggplot in R?
I would like to improve the years in Y axis. How to put the years using intervals (each 2 or 5 years)?
Or how to include a secundary Y axis and interleave Y axis ticks?
year <- seq(1977,2021,1)
jan = runif(45, min=-4, max=4)
feb = runif(45, min=-4,…

Marcel
- 147
- 4
0
votes
0 answers
R code to place labeled lines on top of the rest in line graph produced by ggplot2
Line graph
I have used this code to produce a line graph using ggplot2. Would like red lines to be on top of rest of lines for improved readability. Have spent several hours attempting to do so, but am unsuccessful.
Code:
#Plot linegraph of gene…

Hammonje
- 1
- 1
0
votes
1 answer
Remove whole x-axis and replace it with string in ggplot
I have a geom_rect graph in ggplot:
data = data.frame("x"=c(1,1,1,5,5,7,7,10),
"y"=c(15,12,8,15,10,10,13,15),
"d"=c(1,2,3,4,5,6,7,8))
The code I'm using to create the plot is:
ggplot() +
…

Juan Pablo Rincon
- 19
- 5