One, bar chart
1. Install package install.packages ("VCD");
Library (VCD);
Count<-table (arthritis$improved); #table统计病人的提高情况 (tabular).
Barplot (count,main= "Bar plot", xlab= "Imrovement", ylab= "Count") #水平图
Barplot (count,main= "Bar plot", xlab= "Imrovement", ylab= "Count", Horiz=true) #垂直图
#分组条形图
Count<-table (arthritis$improved,arthritis$treatment);
Barplot (Count,main = "Stacked bar graph", xlab= "treatment", ylab= "F", Col=c ("Red", "yellow", "green"), Legend=rownames (count));
Barplot (count,main = "Group bar graph", xlab= "treatment", ylab= "F", Col=c ("Red", "yellow", "green"), Legend=rownames (count), Beside=true);
Spine (count,main= "Spinogram Example");
#饼图pie (X,labels)
Count<-table (arthritis$improved); #table统计病人的提高情况 (tabular).
Pie (count);
Count
Library ("Plotrix")
Lab<-c ("None", "some", "marked");
Pie3d (count,labels = Lab,explode = 0.1); #三维拼图
# #直方图
Par (Mfrow=c (2,1));
Dat<-a$age
hist (DAT); #最简单的直方图
hist (DAT,
breaks = 20,
Col = "Green",
Xlab = "Age",
Ylab = "cout",
Main = "Ages")
Rug (DAT) #添加轴点;
Lines (Density (DAT), col= "Red", lwd=2) #添加轴线
x<-dat;
Box ();
#核密度图plot (Density)
Par (Mfrow=c (2,1));
Plot (density (DAT));
Polygon (density (DAT), col= "Red", border= "Blue"); #填充颜色
Rug (dat,col= "Brown");
Box ();
#箱图boxplot (min, under four, median, four min, max)
BoxPlot (a,notch=true); #中notch为画出凹图
Boxplot.stats (DAT);
# #小提琴图整体貌似小提琴, the outer shape is the kernel density estimate.
Install.packages ("Vioplot");
Library (Vioplot)
Vioplot (A$age,a$id,names=c ("Age", "ID"), col= "Red");
#点图dotchart (x,labels=)
Dotchart (DAT);
Basic charts in R