zoukankan      html  css  js  c++  java
  • R语言低级绘图函数-points

    points 用来在一张图表上添加点,指定好对应的x和y坐标,就可以添加不同形状,颜色的点了;

    基本用法:

    通过x和y设置点的坐标

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    points(x = c(3, 3), y = c(3, 5))

    效果图如下:

    参数设置:

    cex : 设置点的大小

    代码示例:

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    points(x = c(3, 3), y = c(3, 5), cex = c(2, 4))

    效果图如下:

    lwd : 设置点的边框的宽度

    代码示例:

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    points(x = c(3, 3), y = c(3, 5), cex = 4, lwd = c(2, 4))

    效果图如下:

    pch : 设置点的形状,取值范围为1到25,

    代码示例:

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    index <- 1:25
    start <- 0
    for (i in 1:5) {
    for (j in 1:5) {
    start <- start + 1
    points(x = i, y = j, pch = index[start], cex = 1.5)
    text(x = i, y = j, labels = index[start], pos = 3, offset = 1)
    }
    }

    效果图如下:

    col:  设置点的边框的颜色

    代码示例:

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    index <- 1:25
    start <- 0
    for (i in 1:5) {
    	for (j in 1:5) {
    		start <- start + 1
    		points(x = i, y = j, pch  = index[start], cex = 1.5, col = "red")
    		text(x = i, y = j, labels = index[start], pos = 3, offset = 1)
    	}
    }

    效果图:

     

     bg : 设置点的背景色,其实就是填充色,需要注意的是,只有形状为21到25的点是有填充色的

    代码示例:

    plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = "n")
    index <- 1:25
    start <- 0
    for (i in 1:5) {
    	for (j in 1:5) {
    		start <- start + 1
    		points(x = i, y = j, pch  = index[start], cex = 1.5, bg = "red")
    		text(x = i, y = j, labels = index[start], pos = 3, offset = 1)
    	}
    }

    效果图如下:

  • 相关阅读:
    [转]ASP.Net+XML打造留言薄
    [导入]如何构造一个C#语言的爬虫蜘蛛程序
    [导入]CSS基本布局16例
    [导入]ASP.NET26个常用性能优化方法
    javascript控制cookies及在跳出本页给出提示,是否放弃操作!!
    RunOnBeforeUnload()
    [导入]网易娱乐频道也在用风讯CMS
    etcd集群配置
    openstack上传镜像
    Ambari 节点坏掉不要的节点 无法删除解决方法
  • 原文地址:https://www.cnblogs.com/xudongliang/p/6757037.html
Copyright © 2011-2022 走看看