ggplot(sunspotyear,aes(Year,Sunspots)) + geom_area() # change fill color and alpha ggplot(sunspotyear,aes(Year,Sunspots)) + geom_area(colour = "black",fill = "blue",alpha = .2) 然后我们看一下数据内有分组情况下的作图 library(ggplot2) #read in data data = read.table("area_plot2.t...
frame(group, values) #绘图 ggplot(data_ggp, aes(x = group, y = values)) + geom_bar(stat = "identity") 2.6 用plotly作图 #下载和加载包 install.packages("plotly") library("plotly") #绘图 plot_ly(x = group, y = values, type = "bar") 三、进阶画图 3.1 水平柱状图 和刚刚的初阶...
基础绘图包中的高级绘图函数,包括:plot()泛型函数(generic method)、boxplot()盒型图、barplot()条形图、hist()直方图或金字塔图、pie()饼图、dotchart()克利夫兰点图和coplot()条件图等(后两个有些冷门)。这里有一个实践过程中容易混淆的地方:大部分par()函数的参数(即:函数中的参数,不是低级绘图函数)不仅...
scale_fill_manual() #forbox plot, bar plot, violin plot, etc scale_color_manual() #forlines and points 以下代码设置箱线图的前景色: ggplot(ToothGrowth, aes(x=dose, y=len,color=dose)) +geom_boxplot()+scale_color_manual(values=c("#999999","#E69F00","#56B4E9")) 4,设置Legend 的...
p <- ggplot(data, aes(x = group, y = value)) + geom_bar(stat = "identity", fill = "lightblue") + # 绘制柱状图 geom_hline(yintercept = mean_value, color = "red", linetype = "dashed") + # 绘制均值线 labs(title = "Mean Bar Plot", x = "Group", y = "Value") # 添加...
scale_fill_manual() #forbox plot, bar plot, violin plot, etc scale_color_manual() #forlines and points 以下代码设置箱线图的前景色: ggplot(ToothGrowth, aes(x=dose, y=len,color=dose)) +geom_boxplot()+scale_color_manual(values=c("#999999","#E69F00","#56B4E9")) ...
如果你希望数据处理更加高效,也可以安装tidyverse(包含ggplot2、dplyr等多个强大R包):install.packages("tidyverse")library(tidyverse)PART.3 R语言常见论文图表绘制 Common Academic Graphs in R 接下来,我们来看论文写作中最常用的5种数据可视化类型,并学习如何用R语言绘制它们!1. 柱状图(Bar Chart)—— ...
2 p4<-ggplot()+ geom_errorbar(data=dat02.1, aes(x=x, ymin=mean_value-0.1, ymax=mean_value+sd_value), width=0.3, color="#e27765")+ geom_col(data=dat02.1, aes(x=x,y=mean_value), fill="#daa421")+ geom_point(data=dat02.2, aes(x=x,y=`Signal Density Detected`), color...
(ggplot2)ggplot(data=new.ef4a,aes(x=x,y=value))+geom_boxplot(aes(fill=group),show.legend=FALSE)+scale_fill_manual(values=c("#c0d5e5","#edd2c4"))+scale_x_discrete(labels=c("SNPs","Indels","SVs","SNPs+Indels","SNPs+Indels+SVs"))+labs(x=NULL,y=TeX(r"(\textit{h}${^2}...
ggplot(singer, aes(x=voice.part, y=height)) + geom_boxplot() 图19-5 按发音分的歌手的身高的箱线图 可以看出,低音歌唱家比高音歌唱家身高更高。 创建直方图时只有变量x是指定的,但创建箱线图时变量x和y都需要指定。 geom_histgrom()函数在y变...