1.散点图Scatterplot 2.带环绕的散点图 Scatterplot with Encircling 3.抖动图Jitter Plot 4.计数图Counts Chart 5.气泡图Bubble Plot 6.边际直方图/箱线图Marginal Histogram / Boxplot 7.相关图Correlogram 1.散点图 Scatterplot 数据分析最常用的图无疑是散点图。每当你想了解两个变量之间关系的性质时,第一...
前两种我们看过了,bar类型下面另讲,jitter以后有机会再说,看看其他4种类型: qplot(carat, price, data = diamonds, color=cut, geom = "smooth", main = "smooth") qplot(cut, price, data = diamonds, fill=cut, geom = "boxplot", main = "boxplot") qplot(price, data = diamonds, fill=cut, ...
notch是否有凹槽,更清晰分离2/4和3/4的数据 # geom_point散点图,position="jitter"把点抖动分散开 # geom_rug地毯图,指示数据点分布情况,sides="lr"图形两边同时绘制 ggplot(Salaries, aes(x=rank, y=salary)) +geom_boxplot(fill="cornflowerblue",color="black",notch=TRUE,notchwidth = 0.4) +geom_po...
就打算花几天,就学习如何用R语言绘制数据图散布图(scatter plots) 需要掌握的命令: plot() xyplot() qplot() text...() smoothScatter() matrix() jitter() rbinom() rnorm() lines() lowess() nls() 用的的包: ggplot2 lattice scattersplot3d...你要查的命令即可基础用法: plot...
library(ggplot2) x <- 1:1000 y <- rnorm(1000) plot(x, y, main="Scatter plot by plot()")qplot(x,y, main="Scatter plot by qplot()") 1. 2.2 使用数据框数据 虽然可以直接使用向量数据,但ggplot2更倾向于使用数据框类型的数据作图。使用数据框有几个好处:数据框可以用来存储数值、字符串、因子...
# load package and datalibrary(ggplot2)data(mpg,package="ggplot2")# pre-set the bw theme. 提前设置主题theme_set(theme_bw())g<-ggplot(mpg,aes(cty,hwy))# Scatterplotg+geom_point()+geom_smooth(method="lm",se=F)+labs(subtitle="mpg: city vs highway mileage",y="hwy",x="cty",titl...
1.2 带边界的散点图(Scatterplot With Encircling) 1.3 抖动图(Jitter Plot) 1.4 计数图(Counts Chart) 1.5 气泡图(Bubble Plot) 1.6 边际直方图/箱线图(Marginal Histogram / Boxplot) ...
>png('Scatter plot 2.png')>ggplot(data=mtcars,aes(x=wt,y=mpg))++geom_point(pch=17,color='blue',size=2)++geom_smooth(method='lm',color='red',linetype=2)++labs(title="Automobile Data",x="Weight",y="Miles Per Gallon")>dev.off() ...
scatterplot(~ mpg + disp + drat + wt, data=mtcars, spread=FALSE, lty.smooth=2, main="Scatter Plot Matrix via car Package") spread=FALSE表示不添加展示分散度和对称信息的直线。 再来一个scatterMatrix()函数的使用例子,主对角线的核密度曲线改为了直方图,并且直方图以汽车气缸数为条件绘制。
geom_smooth():平滑线 geom_quantile():分位线 geom_rug():边际地毯线 geom_jitter():避免重叠 geom_text():添加文本注释 散点图 b+geom_point() 将变量cyl映射给点的颜色和形状 b + geom_point(aes(color = factor(cyl), shape = factor(cyl))) ...