gpt4 book ai didi

r - 如何避免使用 ggtern/ggplot2 剪切标签(如 xpd=TRUE)

转载 作者:行者123 更新时间:2023-12-05 02:14:54 26 4
gpt4 key购买 nike

在下面的三元图中,轴外的标签被剪掉了。我找不到避免这种情况的 ggtern()ggplot2 设置。对于基础 R 图形,我只使用 xpd=TRUE

enter image description here

我的数据:

modes <-
structure(list(Mode = c("Literature", "Poetry", "Table", "Map",
"Thematic map", "Graph", "Art", "Diagram", "Statistical analysis",
"Statistical graphics"), Words = c(9L, 7L, 1L, 2L, 2L, 1L, 4L,
2L, 6L, 8L), Numbers = c(0.5, 1, 9, 2, 8, 1, 1, 0, 15, 8), Pictures = c(1L,
4L, 1L, 9L, 14L, 11L, 8L, 9L, 5L, 15L)), .Names = c("Mode", "Words",
"Numbers", "Pictures"), problems = structure(list(row = 10L,
col = NA_character_, expected = "4 columns", actual = "5 columns",
file = "'modes.dat'"), .Names = c("row", "col", "expected",
"actual", "file"), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame")), row.names = c(NA, -10L), spec = structure(list(
cols = structure(list(Mode = structure(list(), class = c("collector_character",
"collector")), Words = structure(list(), class = c("collector_integer",
"collector")), Numbers = structure(list(), class = c("collector_double",
"collector")), Pictures = structure(list(), class = c("collector_integer",
"collector"))), .Names = c("Mode", "Words", "Numbers", "Pictures"
)), default = structure(list(), class = c("collector_guess",
"collector"))), .Names = c("cols", "default"), class = "col_spec"), class = c("tbl_df",
"tbl", "data.frame"))

代码:

library(ggtern)

AES <- (aes(x=Numbers, y=Words, z=Pictures, label=Mode ))

ggtern(data=modes, mapping=AES) +
geom_point(size=3, color="red") +
geom_label(vjust = "bottom") + theme(text = element_text(size=16))

最佳答案

我通过滚动浏览 R Studio 中的 theme_ 建议找到了答案:theme_nomask() 做我想做的。难点在于 ggtern 有自己的三线图约定,这与 ggplot2 的约定不同。

ggtern(data=modes, mapping=AES) +
geom_point(size=3, color="red") +
geom_label(vjust = "bottom") +
theme_nomask() +
theme(text = element_text(size=16))

enter image description here

关于r - 如何避免使用 ggtern/ggplot2 剪切标签(如 xpd=TRUE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52950385/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com