R语言画图功能大全
一、plot()函数:散点图
----#plot是用来画散点图的~左边是因变量;右边是自变量
plot(cars$dist~cars$speed) ,#y~x
main=”Relationship between car distance & speed” ,#表标题
xlab = "Speed(miles per hour)" ,#X坐标轴标题
ylab="Distance travelled (miles)" ,#Y坐标轴标题
xlim=c(0,30) ,#设置X轴范围从0到30
ylim=c(0,140) ,#设置Y轴范围从0到140
xaxs="i" ,#设置X轴风格internal
yaxs="i" ,#设置X轴风格internal
col="red" ,#设置“散点“”的颜色为红色
pch=19 ,#设置散点的形状为实心圆点
二、画线图
sales<-read.csv("dailysales.csv",header=TRUE)
plot(sales$units~as.Date(sales$date,"%d/%m/%y"))
#指定散点图类型为“l”表示画线图
type="l"
main="UnitSales in the month of January 2010"
xlab="Date"
ylab="Number of units sold",col="blue"
运行在R上的实例:
#plot是用来画散点图的~左边是因变量;右边是自变量
plot(cars$dist~cars$speed,xlab="speed",ylab = "ditance",xaxs="i",col="red",pch=19,main="Relation distance & speed")
sales<-read.csv("E:\\R_workspace\\dailysales.csv",header=TRUE)
plot(sal
一、plot()函数:散点图
----#plot是用来画散点图的~左边是因变量;右边是自变量
plot(cars$dist~cars$speed) ,#y~x
main=”Relationship between car distance & speed” ,#表标题
xlab = "Speed(miles per hour)" ,#X坐标轴标题
ylab="Distance travelled (miles)" ,#Y坐标轴标题
xlim=c(0,30) ,#设置X轴范围从0到30
ylim=c(0,140) ,#设置Y轴范围从0到140
xaxs="i" ,#设置X轴风格internal
yaxs="i" ,#设置X轴风格internal
col="red" ,#设置“散点“”的颜色为红色
pch=19 ,#设置散点的形状为实心圆点
二、画线图
sales<-read.csv("dailysales.csv",header=TRUE)
plot(sales$units~as.Date(sales$date,"%d/%m/%y"))
#指定散点图类型为“l”表示画线图
type="l"
main="UnitSales in the month of January 2010"
xlab="Date"
ylab="Number of units sold",col="blue"
运行在R上的实例:
#plot是用来画散点图的~左边是因变量;右边是自变量
plot(cars$dist~cars$speed,xlab="speed",ylab = "ditance",xaxs="i",col="red",pch=19,main="Relation distance & speed")
sales<-read.csv("E:\\R_workspace\\dailysales.csv",header=TRUE)
plot(sal

本文详细介绍了R语言的绘图功能,包括使用plot()函数绘制散点图和线图,通过barplot()函数画柱形图,利用hist()和density()函数展示数据分布,以及如何绘制箱型图、热力图。此外,还讲解了散点图阵、图例添加和多图布局等高级技巧。

2666

被折叠的 条评论
为什么被折叠?



