Questions tagged [geom-area]

47 questions
4
votes
1 answer

geom_area produces blank areas between layers

I have the following data in data.frame tbl: library(tibble) tbl <- structure(list( year = c(2007, 2008, 2008, 2009, 2009, 2010, 2010, 2010, 2011, 2011, 2011, 2011, 2012, 2012, 2012, 2013, 2013, 2013, 2014, 2014, 2014, 2015, 2015, 2015, 2015,…
iod
  • 7,412
  • 2
  • 17
  • 36
3
votes
1 answer

Creating a smooth line when using geom_area in ggplot - R

I am trying to create an area chart with a smooth line using R and ggplot. I am able to create an area chart but I am unable to create a smooth line. I have tried a combination of geom_area and either geom_smooth or stat_summary. Stat_summary…
turtleR
  • 33
  • 5
3
votes
1 answer

Displaying SPEI with ggplot: geom_area ends/starts at different positions when sign changes

Here's some data structure(list(Period = structure(c(2017.83333333333, 2017.91666666667, 2018, 2018.08333333333, 2018.16666666667, 2018.25, 2018.33333333333, 2018.41666666667, 2018.5, 2018.58333333333, 2018.66666666667, 2018.75, 2018.83333333333,…
Felix Phl
  • 383
  • 1
  • 13
2
votes
2 answers

How to stack partially matched time periods with geom_area (ggplot2)?

With the following example, I get a plot where the areas are not stacked. I would like to stack them. This should be a partial stack, intensity starting at 0.5, then reaching 0.8 where stacked, then reaching 0.3 at the end. I assume that the…
2
votes
1 answer

Why is ggplot geom_area empty when attempting to plot a stacked area graph based off aggregated data?

I am attempting to create a stacked area graph to indicate the proportion of tweets per month/year for a assigned Topic. My dataframe has three columns; tweet_time, Topic, count. A head() of which is pasted below. I have looked at similar questions…
SlowBear
  • 71
  • 6
2
votes
0 answers

Problems with vertical scale in stacked area charts using geom_area in ggplot2

I am trying to create a stacked area chart of 4 categories of data using geom_area in R. I am able to construct line charts for the categories using geom_line() but when I use geom_area to show shaded regions, the vertical scale is incorrect. It…
PeterG
  • 23
  • 3
2
votes
1 answer

Impose Line Plots Over a Stacked Area Plot Using Two Different Dataframes

I have code prepared which yields the below stacked area plot: This plot represents the average conditions in a specified area, broken down by species, and is contained within one dataframe (see sample data). I have a second dataframe however which…
UnsoughtNine
  • 63
  • 1
  • 8
2
votes
1 answer

ggplot: How to apply geom_area() or similar to fill area under three distinct geom_line() without overlapping each indepedent fill?

I have a plot based on my data nd with three geom_line() that demonstrates the probability of death after 1-yr: nd$y_et, 3-yrs: nd$y_tre and 5-yrs: nd$y_fem, respectively, as function of number of resected lymph nodes nd$n_fjernet. Question: how can…
cmirian
  • 2,572
  • 3
  • 19
  • 59
1
vote
0 answers

how to change the fill colour a specific value in ggplot geom_area()

If possible I'd like to do this within a ggplot and not mess with making a whole bunch of extra data.frames I have the following example figure, I will be making figures like this a lot so need the ggplot function to be a bit muteable. example <-…
3luke33
  • 37
  • 3
1
vote
1 answer

Selectively remove legend labels

I have 4 labels for my area plot's legend, but I only want to show 2 of those labels: library(ggplot2) tibble( x = rep(1:16, each = 4), y = rnorm(64, mean = 3), labels = factor(rep(1:4, 16)) ) %>% ggplot(aes(x = x, y = y, fill = labels)) + …
at.
  • 50,922
  • 104
  • 292
  • 461
1
vote
1 answer

Is there a way to fix these blank gaps between areas in ggplot?

I have a problem with drawing coloured areas behind the plot of a Normal Distribution. I desire to achieve something like this: enter image description here but without the blank gaps. My code is normal <- function(mu, sigma, x){ …
1
vote
1 answer

gganimate does not work properly in combination with geom_area

I would like to animate a ggplot with gganimate using geom_area with different values for the years between 2000 and 2050. However, for some reason if I include view_zoom to keep the y-axis fixed and to zoom out along the x-axis for around the first…
r-newbie
  • 149
  • 7
1
vote
1 answer

How to make dates in x-axis equidistant in ggplot2 (geom_area) and format date as "%d %b %Y"

I have a recurrent problem driving me nuts ... I am plotting a ggplot2 using '''geom_area''' with my x-axis as dates. I am trying to separate the dates into equal distances between each other, but I cannot see how... I am attaching my dummy data.…
Irene
  • 35
  • 4
1
vote
1 answer

Changing the color of the area under the curve according to a categorical variable (geom_area)

I am trying to draw a curve (with geom_area) where the area under the curve is changing according to a third variable. Here is a reproducible example: data <- data.frame( time = seq(1,10), activity = c(43.59675 ,18.15803 ,26.59981 ,72.64358…
Solo Molo
  • 56
  • 6
1
vote
1 answer

GGPLOT2 : geom_area with ordered character variable as x axis

I have a dataset like the following : dat <- data.frame(sp = c("a", "a", "b", "b", "b", "c", "c"), nb = c(5, 44, 32, 56, 10, 1, 43), gp = c("ds1", "ds2", "ds1", "ds2", "ds3", "ds1", "ds3")) With sp = species ; nb = nb occurrences ; gp = sampling…
RPO
  • 129
  • 5
1
2 3 4