r - ggplot的方面标题中的部分斜体
问题描述
我想知道是否有任何方法可以重命名构面标题,以便它们包含部分斜体和部分非斜体。
这是一些玩具数据
library(Hmisc)
library(dplyr)
# Plot power vs. n for various odds ratios
n <- seq(10, 1000, by=10) # candidate sample sizes
OR <- as.numeric(sort(c(seq(1/0.90,1/0.13,length.out = 9),2.9))) # candidate ORs
alpha <- c(.001, .01, .05) # alpha significance levels
# put all of these into a dataset and calculate power
powerDF <- data.frame(expand.grid(OR, n, alpha)) %>%
rename(OR = Var1, num = Var2, alph = Var3) %>%
arrange(OR) %>%
mutate(power = as.numeric(bpower(p1=.29, odds.ratio=OR, n=num, alpha = alph))) %>%
transform(OR = factor(format(round(OR,2),nsmall=2)),
alph = factor(ifelse(alph == 0.001, "p=0.001",
ifelse(alph == 0.01, "p=0.01", "p=0.05"))))
pPower <- ggplot(powerDF, aes(x = num, y = power, colour = factor(OR))) +
geom_line() +
facet_grid(factor(alph)~.) +
labs(x = "sample size") +
scale_colour_discrete(name = "Odds Ratio") +
scale_x_continuous(breaks = seq(0,1000,100)) +
scale_y_continuous(breaks = seq(0,1,.1), sec.axis = sec_axis(trans=I, breaks=NULL, name="Significance Level")) + # this is the second axis label
theme_light() +
theme(axis.title.x = element_text(size = 12, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
axis.text = element_text(size = 11),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_line(colour = "gray95"),
panel.grid.major.x = element_line(colour = "gray95"),
strip.text = element_text(colour = 'black', face = 'bold', size = 12),
legend.text = element_text(size = 12),
legend.title = element_text(size = 12, face = "bold"))
pPower
有没有办法让分面标题读取“ p = 0.001”、“ p = 0.01”等,而不是“p = 0.001”,即部分斜体和部分非斜体?
解决方案
推荐阅读
- r - SQL 和 T-SQL 的 R 服务,运行多个存储过程时的内存问题
- python - 如何在生成的板上移动我的角色?
- asp.net - razor 命名处理程序和 BindProperty
- r - K 表示聚类 - ID 代替 R 中的索引
- javascript - 使用 Javascript 将标签分别附加到每个数组值
- validation - 使用 Apps 脚本创建使用命名范围的数据验证
- vb.net - 如何从其完整路径(VB.NET)中拆分特定路径中的目录名称
- reactjs - Typescript 模块路径解析不适用于 .js 文件
- php - 如何在 PHPUnit 中对 while 循环进行单元测试?
- c# - C# 值类型赋值是原子的吗?