gpt4 book ai didi

r - ggplot : text printed by geom_text is not clear

转载 作者:行者123 更新时间:2023-12-03 11:22:26 25 4
gpt4 key购买 nike

使用 geom_text 打印的文本不是很清楚。我怎样才能让它更清楚?

data = data.frame(rnorm(1000))
colnames(data) = "numOfX"
m <- ggplot(data, aes(x=numOfX))
m + geom_histogram(colour = "blue", fill = "white", binwidth = 0.5) +
annotate("segment", x=10,xend=10,y=20,yend=0,arrow=arrow(), color="blue") +
geom_text(aes(10, 30, label="Observed \n value"), color = "blue")

enter image description here

最佳答案

使用 annotate对于文本以及箭头:

m + geom_histogram(colour = "blue", fill = "white", binwidth = 0.5) +
annotate("segment", x=10,xend=10,y=20,yend=0,arrow=arrow(), color="blue") +
annotate("text", x=10, y=30, label="Observed \n value", color = "blue")

enter image description here

原因是 geom_text过度绘制数据框中每行数据的文本,而 annotate只绘制一次文本。正是这种过度绘制导致了粗体、像素化的文本。

我相信这个问题最近得到了回答。我会尝试找到一个引用:
最近有人问了一个类似的问题:
  • ggplot2: Is there a fix for jagged, poor-quality text produced by geom_text()?
  • How to nicely annotate a ggplot2 (manual)
  • 关于r - ggplot : text printed by geom_text is not clear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11618392/

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