gpt4 book ai didi

R 不显示 y 值但保留 y 轴

转载 作者:行者123 更新时间:2023-12-04 07:33:43 24 4
gpt4 key购买 nike

我正在尝试重现一个情节。
这是我想重现的原始情节:
enter image description here
这就是我得到的:
enter image description here
这是我在 R 中使用的代码:

library(ggplot2)

df = read.table(sep=",",
header=T,
text="time,bits
1,1
2,1
2,1
2,1
2,1
5,1
5,1
5,1
6,1
6,1
6,1
6,1
6,1
6,1
7,1
7,1
7,1
7,1
7,1
7,1
7,1
7,1")

mapping <- aes(
x = (time)
)
(ggplot(data=df, mapping=mapping)
+ stat_ecdf(geom = "line")
+ geom_vline(xintercept=df$time, linetype="dotted")
+ theme_bw()
+ labs(x = "time t", y = "bits")
+ scale_x_continuous(breaks = c(1,2,5,6,7))
)
我不知道如何从 y 轴上删除值?我发现的大多数帖子都根本不显示 y 轴,我只想隐藏这些值。

最佳答案

您可以在 theme() 中做一些修改像这样:

mapping <- aes(
x = (time)
)
(ggplot(data=df, mapping=mapping)
+ stat_ecdf(geom = "line")
+ geom_vline(xintercept=df$time, linetype="dotted")
+ theme_bw()
+ labs(x = "time t", y = "bits")
+ scale_x_continuous(breaks = c(1,2,5,6,7))
) + theme(axis.ticks.y = element_blank(),
axis.text.y = element_blank())
enter image description here

关于R 不显示 y 值但保留 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67825373/

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