根据列更改标签的字体粗细
Change the label's font weight based on column
我使用 ggplot 为 Python 生成了下图。 x 轴表示 5 月份的天数。
有什么方法可以突出显示属于周末的日子吗?例如,每当列 weekend == 1
?
时,将标签设为粗体
我试过在 theme
和 geom_text
中使用 aes
无济于事。
这样的东西行得通吗? (下面的代码)
by_day <- data.frame(
X=0:6,
weekday=0:6,
variable="Number_of_tweets",
value=c(5820,6965,7415,6800,5819,1753,1137))
# install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)
p <- ggplot(data=by_day, aes(x=weekday, y=value)) +
geom_bar(stat = "identity") +
scale_x_continuous(breaks=0:6,
labels=c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"))
p + theme(axis.text=element_text(face=rep(c("plain", "bold"), c(5,2))))
我使用 ggplot 为 Python 生成了下图。 x 轴表示 5 月份的天数。
有什么方法可以突出显示属于周末的日子吗?例如,每当列 weekend == 1
?
我试过在 theme
和 geom_text
中使用 aes
无济于事。
这样的东西行得通吗? (下面的代码)
by_day <- data.frame(
X=0:6,
weekday=0:6,
variable="Number_of_tweets",
value=c(5820,6965,7415,6800,5819,1753,1137))
# install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)
p <- ggplot(data=by_day, aes(x=weekday, y=value)) +
geom_bar(stat = "identity") +
scale_x_continuous(breaks=0:6,
labels=c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"))
p + theme(axis.text=element_text(face=rep(c("plain", "bold"), c(5,2))))