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)
    	}
    }

    效果图如下:

  • 相关阅读:
    基于角色的权限控制
    C#中实现拖动无边框窗体Form
    C#加密方法汇总
    监控 SQL Server (2005/2008) 的运行状况来自微软TetchNet
    经典SQL语句集锦【转】
    Asp.net+Xml+js实现无线级下拉菜单
    CuteEditor5.0的安装及它与Ajax.net配合无刷新操作数据库!
    sql 提取数字、字母、汉字
    c# 判断远程文件是否存在
    c#采集网页用得几个函数
  • 原文地址:https://www.cnblogs.com/xudongliang/p/6757037.html
Copyright © 2011-2022 走看看