在 R 图中用相同长度但半高的矩形替换正方形 [英] replacing squares with rectangles with same length but half height in R plot

查看:46
本文介绍了在 R 图中用相同长度但半高的矩形替换正方形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否在 BASE R 中使用 symbols() 函数,我可以用相同长度但半高的矩形替换下面图中的正方形吗?

I was wondering if using symbols() function in BASE R, I could replace the squares in my plot below with rectangles of the same length but half height?

plot((8:14)*.1, rep(1, 7), cex = 4, pch = 0)

symbols(rep(1, 7), (8:14)*.1, rectangles = .5) ## Tried this with no success

推荐答案

您需要将整个矩阵指定为 rectangles 的值,而不仅仅是一个数字.另外,默认是使用英寸的大小,但最好通过指定inches=F来使用图片本身的单位.

You need to specify a whole matrix as the value of rectangles, not just a number. Also, the default is to use the size in inches, but it would be better to use the units of the picture itself by specifying inches=F.

RECT = matrix(rep(c(0.04,0.02), each=7), ncol=2)
symbols((8:14)*.1, rep(1,7), rectangles=RECT, inches=F)

我称为 RECT 的变量指定了尺寸.它应该是一个有两列的矩阵.第一列指定矩形的宽度.第二列指定高度.

The variable that I called RECT specifies the sizes. It should be a matrix with two columns. The first column specifies the widths of the rectangles. The second column specifies the heights.

这篇关于在 R 图中用相同长度但半高的矩形替换正方形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆