我试图让xaxis标签中的< =正确显示。我之前看过expression
的帖子。在每个示例中,只有一个标签明确地(手动)完成。在我的例子中,有几个带< =的标签。我从文件中读取了因子标签。
faclab <- "value,label
1,<= 1
2,1 < ... <= 2
3,2< ... <= 3
4,>3"
labels.dt <- fread(faclab)
data <- data.table(value=sample(labels.dt[['value']],100,replace=TRUE))
ggplot(data, aes(factor(value))) + geom_bar(aes(y=(..count..)/sum(..count..))) +
scale_x_discrete(breaks=labels.dt[['value']], labels=labels.dt[['label']])
答案 0 :(得分:2)
将"≤"
替换为相应的unicode字符stringi::stri_replace_all_fixed(
c("<= 1", ">= 2"),
c("<=", ">="),
c("\u2264", "\u2265"),
vectorize_all = F
)
# [1] "≤ 1" "≥ 2"
(library(tidyverse)
library(data.table)
faclab <- "value,label
1,<= 1
2,1 < ... <= 2
3,2< ... <= 3
4,>3"
labels.dt <- fread(faclab)
data <- data.table(value=sample(labels.dt[['value']],100,replace=TRUE))
ggplot(data, aes(factor(value))) + geom_bar(aes(y=(..count..)/sum(..count..))) +
scale_x_discrete(
breaks=labels.dt[['value']],
labels=stringi::stri_replace_all_fixed(labels.dt[['label']], "<=", "\u2264")
)
):
git rm --cached config/initializers/smtp.rb
例如:
config/initializers/smtp.template.rb