R语言-画散点图
plot()函数
plot(cars$dist~cars$speed, # y~x
main="XXX", # 画标题
xlab="XXX", #X坐标轴标题
ylab="XXX", #Y坐标轴标题
xlim=c(0,30), #设置X轴范围为从0到30
ylim=c(0,140), #设置Y轴范围为从0到140
xaxs="i", #设置X轴风格internal
yaxs="i", #设置Y轴风格internal
col="red", #设置“散点”的颜色为红色
pch=19) #设置散点的形状为实心圆点
示例
1.数据:R自带数据集cars
>cars
>plot(cars$dist~cars$speed)
结果如下图:
>cars
> 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", #设置Y轴风格internal
+ col="red", #设置“散点”的颜色为红色
+ pch=19) #设置散点的形状为实心圆点
结果如下图:
2.点图
> library(reshape)
> sales<-melt(citysales) #把宽表融合成窄表
> sales$color[sales[,2]=="ProductA"] <- "red" #sales数据增加color这一列
> sales$color[sales[,2]=="ProductB"] <- "blue"
> sales$color[sales[,2]=="ProductC"] <- "violet"
> dotchart(sales[,3], #画点图
+ labels=sales$City, #标城市名
+ groups=sales[,2], #按第二列分类
+ col=sales$color,pch=19,
+ main="Sales Figures",
+ xlab="Sales Revenue (1,000's of USD)")
R语言-画散点图的更多相关文章
- R语言-画线图
R语言分高水平作图函数和低水平作图函数 高水平作图函数:可以独立绘图,例如plot() 低水平作图函数:必须先运行高水平作图函数绘图,然后再加画在已有的图上面 第一种方法:plot()函数 > ...
- R语言画棒状图(bar chart)和误差棒(error bar)
假设我们现在有CC,CG,GG三种基因型及三种基因型对应的表型,我们现在想要画出不同的基因型对应表型的棒状图及误差棒.整个命令最重要的就是最后一句了,用arrows函数画误差棒.用到的R语言如下: d ...
- R语言画点状误差线
现在项目需要R语言做几个线性拟合,画一些点图,突然需要画误差线,网上找了下,可以用代码实现..效果如下 xx1<-c(xxxxxx,xxxx,xxxxx) yy1<-c(xxxxxx,xx ...
- r语言之散点图绘制及参数
一个简单的例子: > plot(cars$dist~cars$speed,+ main="车位移与速度的关系",+ xlab="速度",+ ylab=&q ...
- R语言画全基因组关联分析中的曼哈顿图(manhattan plot)
1.在linux中安装好R 2.准备好画曼哈顿图的R脚本即manhattan.r,manhattan.r内容如下: #!/usr/bin/Rscript #example : Rscript plot ...
- r语言之散点图类型type参数
type参数用来控制所生成散点图的类型,有如下几个选项: type=“p”表示绘制单独的点 type=“l”表示绘制点连成的折线 type=“b”表示有线连接的点 type=“o”表示将点绘在线上 t ...
- R语言画曲线图
本文以1950年到2010年期间我国的火灾统计数据为例,数据如下所示: (0)加载数据 data<-read.csv("E:\\MyDocument\\p\\Data\\1950~20 ...
- 用R语言 画条形图(基于ggplot2包)
1.用qplot(x,data=data,geom.=”bar”,weight=y)+scale_y_continuous("y")画出y关于x的条形. 图中提示binwidth这 ...
- R语言画云字图
install.packages('wordcloud') library(wordcloud) colors=c('red','blue','green','yellow','purple') da ...
随机推荐
- python hashillb 模块
hashlib主要提供字符加密功能,将md5和sha模块整合到了一起,支持md5,sha1, sha224, sha256, sha384, sha512等算法 import hashlib # ## ...
- [java,2018-02-01] quartz定时任务中时间表达式
格式: [秒] [分] [小时] [日] [月] [周] [年] 序号 说明 是否必填 允许填写的值 允许的通配符 1 秒 是 ...
- LInux下的jdk环境置
1.Linux下使用wget下载jdk8: 进入目录/usr/local/software 2.解压 tar -zxvf jdk-8u152-linux-x64.tar.gz 3.配置环境变量 vi ...
- IntelliJ Idea设置Could not autowire. No beans of 'xxx' type found
1.问题描述 在Idea的spring工程里,经常会遇到Could not autowire. No beans of ‘xxxx’ type found的错误提示.但程序的编译和运行都是没有问题的, ...
- 国内好的python学习地址
python3官方在线文档https://docs.python.org/3/ 玩蛇网http://www.iplaypy.com/ python中文网 http://bbs.pythontab.co ...
- leetcode1007
public class Solution { public int MinDominoRotations(int[] A, int[] B) { var na = A.Length; var nb ...
- Human Interface Device (HID) Class Decoder
http://www.usblyzer.com/usb-human-interface-device-hid-class-decoder.htm Human Interface Device (H ...
- windows下Jenkins环境搭建
Jenkins简介 Jenkins是一个开源软件项目,业界著名的持续集成工具. Jenkins 安装准备 1. 安装java 并且配置jdk环境 2. 到Jenkins官网下载Je ...
- 机器学习进阶-图像特征sift-SIFT特征点 1.cv2.xfeatures2d.SIFT_create(实例化sift) 2. sift.detect(找出关键点) 3.cv2.drawKeypoints(画出关键点) 4.sift.compute(根据关键点计算sift向量)
1. sift = cv2.xfeatures2d.SIFT_create() 实例化 参数说明:sift为实例化的sift函数 2. kp = sift.detect(gray, None) 找出 ...
- java byte[]与十六进制字符串相互转换
http://blog.csdn.net/worm0527/article/details/69939307 http://blog.csdn.net/androiddeveloper_lee/art ...