R 语言画图的基本参数

点的种类

点的种类参数为 pch,每一种符号对应一个数字编号

# 点有25种,为了展示25种点
x = 1:25
y = 1:25
x
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## [24] 24 25
plot(x, x, pch = x)
# 在图上随意添加点
lines(10, 15, type = "b", pch = 5)

# type的含义
plot(x, y, type = "p", pch = x) #point 仅仅画出点

plot(x, y, type = "l", pch = x)  #line 仅仅画出线

plot(x, y, type = "b", pch = x)  #both 同时画出点线,注意和o的区别,没有覆盖

plot(x, y, type = "c", pch = x)  #  画出线,但是点所在的位置为空

plot(x, y, type = "o", pch = x)  #overlap  画出点线,线覆盖点

plot(x, y, type = "s", pch = x)  #step  台阶

plot(x, y, type = "h", pch = x)  #hist  类似直方图

plot(x, y, type = "n", pch = x)  #none  一个空白


点的大小

点的大小的参数为cex

plot(x, x, pch = x, cex = x)

线

线的种类

线的种类参数为lty

# 首先来一个比较简单的数据
a = c(1, 10)
plot(a, a, type = "b", lty = 1)

plot(a, a, type = "b", lty = 2)
# 6种线,分别对应lty = 1,2,3,4,5,6
# 通过在图上添加参考线来认识一下这六种线 添加参考线的函数为abline ?abline()
b = 1:6
abline(h = b, lty = b)
abline(v = b, lty = b)
abline(a = 4, b = 5, lty = b)
abline(a = 0, b = 5, lty = b)

线的粗细

线的粗细的参数为lwd

abline(h = b, lty = b, lwd = b)
## Error: plot.new has not been called yet
plot(x, y, lwd = 1)
plot(a, a, type = "b", lwd = 5)
plot(a, a, type = "b", lwd = 1)

色的参数为col

# 颜色可以用我们单词表示
plot(x, x, col = "blue", pch = 20) #颜色名称

plot(x, x, col = "red", pch = 20)  #颜色名称


# 或者用数字表示
plot(x, x, col = 1, pch = 20) #颜色下标

plot(x, x, col = 2, pch = 20)

plot(x, x, col = "#FFFFFF", pch = 20)  #16进制颜色值

plot(x, x, col = "#0000FF", pch = 20)  #蓝色

plot(x, x, col = rgb(0.5, 0.5, 0.5), pch = 20)  #RGB red,green,black

plot(x, x, col = hsv(0, 0, 0.5), pch = 20)  #hsv 色相-饱和度-亮度

# 彩虹型颜色
plot(x, x, col = rainbow(10), pch = 20)

pie(rep(1, 10), col = rainbow(10))

# 多阶灰度
pie(rep(1, 10), col = gray(0:10/10))

我们肯定是记不住这么多颜色的,所以这里有一个专门整理好的网站,供我们参考 http://research.stowers-institute.org/efg/R/Color/Chart/

R 语言画图的基本参数的更多相关文章

  1. R语言画图教程之盒形图

    R语言画图教程之盒形图 我们之前有分享过一系列的R语言画图代码(PCA图.Pathway图.火山图.RDA图.热图),今天再来补充一个盒形图(箱形图)的代码. 以下代码只是示例,不能直接搬来用哦,注意 ...

  2. R语言画图小结

    本文以1950年到2010年期间我国的火灾统计数据为例,数据如下所示: (0)加载数据 data<-read.csv("E:\\MyDocument\\p\\Data\\1950~20 ...

  3. R语言基本绘图-plot参数:标题,坐标轴和颜色

    标题 plot(c(1:2,2:4),main = "这是主标题",sub = "这是副标题",xlab = "这是x轴", ylab = ...

  4. [R语言画图]气泡图symbols

    绘制气泡图主要使用函数symbols(x,y,circle=r).当中x.y是坐标轴,r是每一个点的半径. x<-rnorm(10) y<-rnorm(10) r<-abs(rnor ...

  5. R语言画图基础参数设置

    Graphical Parameters You can customize many features of your graphs (fonts, colors, axes, titles) th ...

  6. R语言︱画图

    笔者寄语:不论画啥,你先plot准没错. plot 二维坐标绘图 dotchart 点图 barplot 条形图 hist 直方图 pie 饼图 points 添加点 lines 添加线 text 添 ...

  7. R语言grid包just参数如何just图形位置

    思路   grid的画图函数都含有just,但是just参数的是怎么调节图形位置的总是让人非常费解,于是便写了代码来一探究竟.   思路非常简单:放一个2*2的布局viewport,每个布局里面放一个 ...

  8. R语言 使用命令行参数运行R程序

    args_test.R 代码如下: Args <- commandArgs()cat("Args[1]=",Args[1],"\n")cat(" ...

  9. R语言画图

    转http://www.cnblogs.com/jiangmiaomiao/p/6991632.html 0 引言 R支持4种图形类型: base graphics, grid graphics, l ...

随机推荐

  1. Statement和PreparedStatement的特点 MySQL数据库分页 存取大对象 批处理 获取数据库主键值

    1 Statement和PreparedStatement的特点   a)对于创建和删除表或数据库,我们可以使用executeUpdate(),该方法返回0,表示未影向表中任何记录   b)对于创建和 ...

  2. [转] Android自动测试之monkeyrunner工具(二)

    monkeyrunner工具  前言: 最近开始研究Android自动化测试方法,对其中的一些工具.方法和框架做了一些简单的整理,其中包括android测试框架.CTS.Monkey.Monkeyru ...

  3. 基于邻接矩阵的广度优先搜索遍历(BFS)

    题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2141&cid=1186 #include<stdio.h> #incl ...

  4. mssql查找备注(text,ntext)类型字段为空的方法

    在sql语句中,如果查找某个文本字段值为空的,可以用select * from 表 where 字段='' ,但是如果这个字段数据类型是text或者ntext,那上面的sql语句就要出错了. 解决办法 ...

  5. SGU 438 The Glorious Karlutka River =) ★(动态+分层网络流)

    [题意]有一条东西向流淌的河,宽为W,河中有N块石头,每块石头的坐标(Xi, Yi)和最大承受人数Ci已知.现在有M个游客在河的南岸,他们想穿越这条河流,但是每个人每次最远只能跳D米,每跳一次耗时1秒 ...

  6. OK335xS can't reset with reboot

    /*********************************************************************** * OK335xS can't reset * 说明: ...

  7. Spring 教程(一)

    一.Spring是什么 通常说的Spring其实指的是Spring Framework,它是Spring下的一个子项目,Spring围绕Spring Framework这个核心项目开发了大量其他项目, ...

  8. HDU 5675 ztr loves math

    ztr loves math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  9. 《深入Java虚拟机学习笔记》- 第4章 网络移动性

    Java虚拟机学习笔记(四)网络移动性

  10. SoapUI入门

    注:需要使用发布的webService接口 我们一般用的是impl接口调用,不大用得上soapUI.看到一份简历上写了使用soapUI做webService测试,想了解一下什么是soapUI soap ...