角落缺少geom_tile边框 [英] geom_tile border missing at corners
本文介绍了角落缺少geom_tile边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下数据框:
# Dummy data frame
df <- expand.grid(x = 1:3, y = 1:3)
我想像这样使用ggplot2
将其绘制为geom_tile
:
I would like to plot it as a geom_tile
using ggplot2
like so:
# Tile plot
ggplot(df) +
geom_tile(aes(x = x, y = y),
fill = NA, colour = "red", size = 3, width = 0.7, height = 0.7)
给出,
但是,请注意,在每个图块的左上角都缺少一个缺口,该缺口的边界与边缘没有很好地吻合.如果使用geom_rect
,则会得到相同的结果.有避免这种情况的解决方法吗?
Notice, however, that in the top left corner of each tile there is a notch missing where the border doesn't quite dovetail correctly. I get the same result if I use geom_rect
. Is there a workaround to avoid this?
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 attached packages:
[1] ggplot2_3.1.0 kitchendraw_0.1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 rstudioapi_0.8 bindr_0.1.1 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.3-2
[8] R6_2.3.0 rlang_0.3.0.1 plyr_1.8.4 dplyr_0.7.7 tools_3.5.1 grid_3.5.1 gtable_0.2.0
[15] withr_2.1.2 yaml_2.2.0 lazyeval_0.2.1 assertthat_0.2.0 tibble_1.4.2 crayon_1.3.4 bindrcpp_0.2.2
[22] purrr_0.2.5 glue_1.3.0 labeling_0.3 compiler_3.5.1 pillar_1.3.0 scales_1.0.0 pkgconfig_2.0.2
根据以下评论更新的数字
Updated figure in response to a comment below
推荐答案
此问题已由此更新为ggplot2
.
这篇关于角落缺少geom_tile边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文