1

我想根据我拥有的 tictactoe 板创建一个连接四板。然而,事情听起来不匹配,我没有完全正确的结果。我想要6行7列!

par(pty="s") # square plot type
x = rep(1:6, each = 6)
y = rep(1:7, times = 7)
symbols(x, y, squares=rep(1, times=42),
        inches=FALSE, # match squares to axes
        xlim=c(0,7),
        ylim=c(8,0)) # flip y axis to match matrix format
board = matrix(rep("E", times=42), nrow=6, ncol=7)

我收到这个错误:

Error in xy.coords(x, y, xlab = deparse(substitute(x)), ylab = deparse(substitute(y))) : 
  'x' and 'y' lengths differ

在此处输入图像描述

下面是 tictactoe 的代码和之后显示的板子:

par(pty="s") # square plot type
x = rep(1:3, each = 3)
y = rep(1:3, times = 3)
symbols(x, y, squares=rep(1, times=9),
        inches=FALSE, # match squares to axes
        xlim=c(0,4),
        ylim=c(4,0)) # flip y axis to match matrix format
board = matrix(rep("E", times=9), nrow=3, ncol=3)

在此处输入图像描述

将第 2 行和第 3 行更改为以下内容后:

x = rep(1:6, each = 7); y = rep(1:7, times = 6)

我得到了以下情节。你知道为什么水平线是这样的吗?并且不锐利并且它们模糊? 在此处输入图像描述

4

1 回答 1

1
par(pty="s") # square plot type
x = rep(1:7, each = 6)
y = rep(1:6, times = 7)
symbols(x, y, squares = rep(1, times=42),
        inches=FALSE, # match squares to axes
        xlim=c(0,8),
        ylim=c(8,0),
        axes = FALSE,
        xlab = '', ylab = '') # flip y axis to match matrix format
board = matrix(rep("E", times=42), nrow = 6, ncol = 7)

在此处输入图像描述

如果您愿意,您可以重新添加轴、刻度和标签

于 2014-03-22T00:39:56.143 回答