Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

Plot labels at ends of lines in stacked area chart

$
0
0

I have the following code

library(ggplot2)
library(dplyr)

# create data
time <- as.numeric(rep(seq(1,7),each=7))  # x Axis
value <- runif(49, 10, 100)               # y Axis
group <- rep(LETTERS[1:7],times=7)        # group, one shape per group
data <- data.frame(time, value, group)

# stacked area chart
ggplot(data, aes(x=time, y=value, fill=group)) + 
  geom_area()+
  geom_text(data = data %>% filter(time == last(time)), aes(label = group, 
                                                               x = time + 0.5, 
                                                               y = value, 
                                                               color = group)) + 
  guides(color = FALSE) + theme_bw() + 
  scale_x_continuous(breaks = scales::pretty_breaks(10))

Where i getenter image description here

But i am aiming for link

Is there any solution for stacked area plot?


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>