gpt4 book ai didi

r - 删除图中的文本

转载 作者:行者123 更新时间:2023-12-04 07:19:55 34 4
gpt4 key购买 nike

我正在使用 library(plotrix) 中的绘图函数 sizetree(版本:3.8-1)。此函数有一个 showcount 参数,允许括号中的一些计数显示在绘图上(见下图)。

但我想知道为什么当我使用 showcount=FALSE 时,它们周围的计数和括号不会消失?有什么办法可以让它们消失吗?

h = "
sssss ooooooo ggggg tttt
a 1 1 0
a 2 1 1
b 1 1 0
b 1 2 0
c 2 1 0
c 3 2 1
d 1 1 0
d 1 1 0
e 1 1 0"
h = read.table(text=h,h=T)

library(plotrix)
plotrix::sizetree(h,showcount = FALSE)

enter image description here

最佳答案

这个函数似乎有一个错误。该函数递归地调用自身以添加每一列,但该函数忽略了将 showcount 值传递给每个后续调用。这是“修补”该功能的一种方法。本质上,我们正在复制并更改一行代码。这种方法非常脆弱,可能很容易与其他版本的包一起破坏,但这已经用 plotrix_3.7-8 进行了测试。

sizetree <- plotrix::sizetree
environment(sizetree) <- globalenv()
# This "path" navigates the AST for the function to find the offending line of code
path <- c(8, 3, 5, 4, 2, 3, 2, 3, 2, 3, 8, 3, 5)
orig <- body(sizetree)[[path]]
orig
## Problem line, no showcount= parameter
# sizetree(nextx, right, top, right + 1, lastcenter = top - xfreq[bar]/2,
# showval = showval, stacklabels = stacklabels, firstcall = FALSE,
# col = newcol, border = border, base.cex = base.cex)
## fix it up
scall <- orig
scall$showcount <- quote(showcount)
body(sizetree)[[path]] <- scall

然后我们就可以运行了

sizetree(h,showcount = FALSE)

得到 sizetree without counts

关于r - 删除图中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68570119/

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