Basic charts in R

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.