代码语言:javascript 代码运行次数:0 运行 AI代码解释 ibrary(ggplot2)ggplot(df,aes(x=year,y=auth_num,col=journal,fill=journal))+stat_summary(fun.data="mean_cl_boot",geom="ribbon",#width=.2,alpha=I(.5))+stat_summary(fun="mean",geom="line")+labs(x="Year",y="Mean number of authors...
之前我们学习了ggplot绘制单变量,两个连续变量的图形,两个离散型变量。对于一个离散型变量,一个连续型变量,有很多作图方式,包括箱图,点图等等 • geom_boxplot() for box plot• geom_violin() for violin plot• geom_dotplot() for dot plot• geom_jitter() for stripchart• geom_line() ...
# Basic line plotggplot(data=economics, aes(x = date, y = pop))+ geom_line()# Plot a subset of the datass <- subset(economics, date > as.Date("2006-1-1")) ggplot(data = ss, aes(x = date, y = pop)) + geom_line() Change line size : ggplot(data = economics, aes(x =...
ggplot(economics, aes(x=date)) + geom_line(aes(y = psavert), color = "darkred") + geom_line(aes(y = uempmed), color="steelblue", linetype="twodash") + theme_minimal()require(reshape2)df <- melt(economics[, c("date", "psavert", "uempmed")], id="date")ggplot(df,...
library(ggplot2) # Basic line plot with points ggplot(data=df, aes(x=dose, y=len, group=1)) + geom_line()+ geom_point() # Change the line type ggplot(data=df, aes(x=dose, y=len, group=1)) + geom_line(linetype = "dashed")+ geom_point() # Change the color ggplot(data=...
Line plot with a numeric x-axis If the variable on x-axis is numeric, it can be useful to treat it as a continuous or a factor variable depending on what you want to do : # Create some data df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3), dose=rep(c("0.5", "1...
R语言ggplot2折线图(line plot)添加置信区间(CI)展示学术论文作者数量的变化趋势,非常有意思的数据可视化案例,原文提出的问题是学术论文中的作者数量有逐年增加的趋势;于是利用R语言里的rplos包抓取了Plos系列...
• geom_line() for line plot • geom_bar() for bar plot 今天我们介绍一下小提琴图 library(ggplot2) data("ToothGrowth") ToothGrowth$dose <- as.factor(ToothGrowth$dose) head(ToothGrowth) 我们先建立一个图层,以dose为X轴,len为Y轴
Basic line plot A subset ofrestaurantdata is used : df<-restaurant[c(1,4), c("time", "total_bill")] head(df) ## time total_bill ## 1 Lunch 13.53 ## 4 Dinner 17.42 # Basic line plot of the values of "total_bill" variables ggplot2.lineplot(data=df, xName="time", yName='...
options(repr.plot.width = 2, repr.plot.height = 6, repr.plot.res = 300) p1 <- base + theme(axis.line = element_line(colour = "grey50", size = 1)) p2 <- base + theme(axis.text = element_text(color = "red", size = 12)) p3 <- base + theme(axis.text.x = element_text...