R语言 polygon()用法及代码示例 |
您所在的位置:网站首页 › r语言lty函数 › R语言 polygon()用法及代码示例 |
R 语言中的 polygon() 函数用于在现有绘图中的指定点之间绘制多边形。 用法: polygon(x_coordinates, y_coordinates)参数:x_coordinates, y_coordinates:绘制多边形的图的 x, y 坐标 返回:给定图中的多边形 范例1:在 R 图中绘制方形多边形 # R program to draw a polygon # Draw an empty plot plot(2, 2, col = "white", xlab = "X", ylab = "Y") # Draw a polygon polygon(x = c(2.7, 2.3, 2.2, 2.8), # X-Coordinates of polygon y = c(2.6, 2.8, 2.4, 2), # Y-Coordinates of polygon col = "darkgreen")输出: 范例2:多边形的颜色边界 # R program to draw a polygon # Draw empty plot plot(2, 2, col = "white", xlab = "X", ylab = "Y") # Draw a polygon polygon(x = c(2.7, 2.3, 2.2, 2.8), # X-Coordinates of polygon y = c(2.6, 2.8, 2.4, 2), # Y-Coordinates of polygon col = "darkgreen", # Color of polygon border = "red", # Color of polygon border lwd = 8) # Thickness of border输出: 这里,border 指定边框颜色,lwd 指定边框粗细。 范例3:绘制频率多边形 # R program to draw a polygon # X values for frequency polygon x1 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |