【发布时间】:2019-05-30 18:18:30
【问题描述】:
当我使用 ggplot 并尝试将图例名称从“值”更改为“工作计划”时,不会改变。以及规模 0 - 没有工作; 1-确实有效。你知道我的代码有什么问题吗:
plot <- ggplot(df3, aes(x = time, y = index, fill = value)) +
geom_raster() +
facet_grid(~ day) +
theme(panel.spacing = unit(1, "mm"),
axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(x="Hours", y ="Identification Number") +
scale_x_continuous(breaks = c(9,17), name= "Time") +
scale_y_continuous()
plot + annotate("rect", fill = "red", alpha = 0.5, xmin = c(9), xmax = c(17), ymin = -Inf, ymax = Inf) +
ylab ("Identification number") +
theme_bw()
【问题讨论】:
-
labs(fill = "Work schedules") -
@Jordo82 谢谢,但如何更改图例中的比例名称? 0 - 不工作; 2 - 工作;我试过 scale_manuel scale_shape_discrete(name=("Work schedules"),breaks=c(2, 0),labels=c("Worked", "Dod not working"))
-
See here 提出一个人们可以帮助解决的 R 问题。这包括数据样本、所有必要的代码,以及对您正在尝试做的事情和没有奏效的事情的清晰解释。
标签: r dataframe ggplot2 legend