gpt4 book ai didi

从 coord_polar x 轴标签中删除最后一个标签和斜线字符 "/"

转载 作者:行者123 更新时间:2023-12-02 02:15:48 24 4
gpt4 key购买 nike

这有点困扰我 - 我怎样才能删除这个不需要的标签,包括 /。简单地像 c("", myactual labels) 没有帮助,因为 / 仍然存在。

我认为也许 scale_x_date 可能会有所帮助,但这实际上绘制了整个日期范围,并且没有给出所需的“按月”数字。

library(ggplot2)
# modified from mdeaths data set
lungdeath <-
structure(list(deaths = c( 2134, 1863, 1877, 1877, 1492, 1249, 1280, 1131, 1209, 1492, 1621, 1846, 1846
), month = c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0
), year = c( 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974, 1974
)), row.names = c( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "121"
), class = "data.frame")

ggplot(lungdeath) +
geom_line(aes(month, deaths)) +
coord_polar() +
scale_x_continuous(breaks = 0:12, labels = c("undesired",1:12))

reprex package 于 2021 年 4 月 21 日创建(v2.0.0)

最佳答案

scale_x_continuous() 中将间隔更改为 1:12:

ggplot(lungdeath) +
geom_line(aes(month, deaths)) +
coord_polar() +
scale_x_continuous(breaks = c(1:12))

enter image description here

关于从 coord_polar x 轴标签中删除最后一个标签和斜线字符 "/",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67202809/

24 4 0