我有以下数据框:
# Dummy data frame
df <- expand.grid(x = 1:3, y = 1:3)
Run Code Online (Sandbox Code Playgroud)
我想把它描绘成一个像这样的geom_tile使用ggplot2:
# Tile plot
ggplot(df) +
geom_tile(aes(x = x, y = y),
fill = NA, colour = "red", size = 3, width = 0.7, height = 0.7)
Run Code Online (Sandbox Code Playgroud)
这使,
但请注意,在每个瓷砖的左上角,缺少一个缺口,其中边框不能正确地吻合.如果我使用,我会得到相同的结果geom_rect.有没有解决方法来避免这种情况?
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other …Run Code Online (Sandbox Code Playgroud)