This site shows the rise of coViD variants over a period of time
What is the best way to achieve this in R. I tried area plot using ggplot2. I have sharp peaks and unable to smoothen them out. Attached is the image I got using area plot in ggplot2.
This site shows the rise of coViD variants over a period of time
What is the best way to achieve this in R. I tried area plot using ggplot2. I have sharp peaks and unable to smoothen them out. Attached is the image I got using area plot in ggplot2.
Its a stacked plot you can make it in ggplot via https://ggplot2.tidyverse.org/reference/position_stack.html
you can also try geom_density
library(ggplot2)
ggplot(data=diamonds, aes(x=price, group=cut, fill=cut)) +
geom_density(adjust=1.5, position="fill") +
theme_bw()
Created on 2022-08-21 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)
Thank you. g <- ggplot(avg_df, aes(x = mean, fill=variable))+ geom_density(position = "fill") + guides(fill = guide_legend(title = "SC-2 variants")) + scale_fill_manual(values=colors) + facet_grid(~State, scales='free_x')
I am unable to plot it with Date as the x axis. I need the date as the x axis with the abundance as the y axis.
I apologize. I wasn't clear. I want the dates plotted against the abundance. But in geom density, since it will plot against only the density its not plotting when I have x = Date and y mean. ggplot(data=avg_df, aes(x=Date, fill=variable)) +
geom_density(adjust=1.5, position="fill") +
theme_bw()
The above works. I get something like this graph.
When I do this code... ggplot(data=avg_df, aes(x=Date, y=mean, fill=variable)) +
geom_density(adjust=1.5, position="fill") +
theme_bw()
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
some plotting data
g <- ggplot(subset(avg_df, State %in% c("State_name")), aes(x = Date, y = mean))+ geom_area(aes(fill = variable)) + guides(fill = guide_legend(title = "SC-2 variants")) + scale_fill_manual(values=met.brewer("Demuth")) + facet_grid(~State, scales='free_x') + theme(panel.spacing = unit(.5, "lines"), panel.border = element_rect(color = "black", fill = NA, size = 2), strip.background = element_rect(color = "black", size = 1.5))