Questions tagged [geom-ribbon]
37 questions
1
vote
0 answers
Smooth a plot and add confidence intervals with R (smooth and geom_ribbon functions on ggplot2)
I have a numeric variable called 'SP', and an ordinal variable called 'DELAY' with 7 conditions (0.1 ; 0.2 ; ... ; 1.2).
For each of my observations, there are 7 SP values, 1 for each DELAY condition.
Each observation also belongs to a group, 1, 2…

Salomé Leclercq
- 31
- 2
1
vote
0 answers
Combine geom_function and geom_ribbon in ggplot2
I would like to highlight the area between two function curves plotted with geom_function.
For example, I create two curves:
ggplot() + geom_function(fun = function(x){x^2}) + geom_function(fun = function(x){x^2 + 1})
How can I highlight the area…

Marcel Schmitt
- 11
- 2
1
vote
1 answer
ggplot2: drawing a area between two values
I have the following dataframe:
df <- data.frame(
time = factor(c(1, 1, 2, 2)),
value = c(1, 5, 3, 4),
group = factor(c(1, 2, 1, 2)),
upper = c(1.1, 5.3, 3.3, 4.2),
lower = c(0.8, 4.6, 2.4, 3.6)
)
I want to plot the column "value" as a…

Paula
- 497
- 2
- 8
1
vote
1 answer
Shade Area between crossing lines differently with ggplot
I would like to shade the area of the following plot with different colors. I would like to shade it in green to the right of the green line and red to its left.
I've already seen this similar question but I would like to do it in ggplot:
Similar…

Pietro
- 347
- 1
- 3
- 15
0
votes
0 answers
error appeared when trying out the geom_ribbon function
I am trying to create a geom_ribbon chart, but the plot only shows the axes, without the plots.
The codes I wrote:
install.packages("tidyverse")
library("tidyverse")
data("diamonds")
ggplot() +
geom_ribbon(data=diamonds,
mapping = aes(
…

Kiki Liu
- 27
- 3
0
votes
2 answers
R add ribbon to stat_summary for median for different datasets
I don't have a solution for my problem. I want to present three different median lines from a dataset which works without a problem. Now I would like to add a ribbon for the IQR or errorbars which would require calculation of upper and lower…

Philipp
- 9
- 3
0
votes
0 answers
How to use geom_ribbon in ggplot for ribbon plot in R
I have tried ribbon plot in R,but my output is not correct ,Can anyone tell whats the problem with my code,thanks in advance
Output for ribbon plot
library(tidyr)
library(ggplot2)
library(dplyr)
library(reshape2)
library(tidyverse)
data =…

Tanvi Birla
- 11
- 1
0
votes
0 answers
Plotting future uncertainty on line graph with ggplot in R
I am looking for a way in ggplot to plot an historic line of data which then merges into a shaded area representing future uncertainty (like the GHG emissions graphs below - but at the moment I just want one trajectory into the future - and even…

DJD
- 31
- 3
0
votes
1 answer
Adding geom_ribbon to geom_line from secondary dataframe
I'm trying to display my model fit and data points on the same plot with ggplot, but can't figure out how to add my calculated SE bands (pred$conf.low, pred$conf.high) to my model line (pred$predicted).
> head(toad2,5)
num DO
753 0 8.41
755 …

Nate
- 411
- 2
- 10
0
votes
1 answer
How to correctly specify a column as the fill colour in geom_ribbon?
I can't seem to be able to set different fill colours for geom_ribbon(), using one of the columns as input to fill
library(ggplot2)
time <- as.factor(c('A','B','C','D'))
grouping <- as.factor(c('GROUP1','GROUP1','GROUP1','GROUP1',
…

brucezepplin
- 9,202
- 26
- 76
- 129
0
votes
1 answer
Two geom_ribbon
I want some figure like this
two geom_riboon from: https://doi.org/10.1016/j.neuroimage.2019.116060
This is head of my data:
time mean sem class
1 -200 -0.03459213 0.002035373 n
2 -196 -0.03065102 0.001801943 n
3 -192…

Amir Asaadi
- 35
- 4
0
votes
1 answer
R plotly - wrong display when overlaying semi-transparent objects (in my case geom_ribbon)
When I run the following lines:
library(plotly)
set.seed(1)
x <- 1:100
y1 <- sin(seq(1, 2*pi, length.out = 100))
y2 <- cos(seq(1, 2*pi, length.out = 100))
plotdata <- rbind(data.frame(x=x, fct = replicate(100, 'sin'), y=y1, lower = (y1+runif(100,…

bchate
- 145
- 9
0
votes
1 answer
How to define xaxis for a cumulative distribution function using ggplot and geom_ribbon in R?
I'm trying to produce a cumulative function using ggplot and stat_ecdf. Since I need the area under the curve to be colored, I'm using geom=="ribbon".
I need the x axis to be as highest as 20, however, I want to estimate the cumulative function…

Adriana Castillo Castillo
- 170
- 1
- 9
0
votes
0 answers
Interrupted or no ribbon ggplot geomribbon or stat_summary
I have a df that looks like this:
ID Genotype Time10min N mean sd se ci
43 1 k_DMSO 43 10 0.029318750 0.009793853 0.0030970883 0.007006100
44 1 k_DMSO 44 10 0.008825716 0.005164837…

Tahnee
- 77
- 5
0
votes
1 answer
R - geom_ribbon() with not unique x-values
I have a problem with the function geom_ribbon (R).
My dataset has not unique x values (i.e. vertical lines on the plot).
How can I set the correct value of aes(x) of the function geom_ribbon?
This is the dataset:
DF
# A tibble: 12 x 5
# Groups: …

Ylenia Rotalinti
- 5
- 1