Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R GGPLOT标签设计(粗体、间隙)_R_Ggplot2_Tidyverse - Fatal编程技术网

R GGPLOT标签设计(粗体、间隙)

R GGPLOT标签设计(粗体、间隙),r,ggplot2,tidyverse,R,Ggplot2,Tidyverse,我使用GGPLOT和 ggplot(MyDF, aes(x=type, y=count, fill=type)) + geom_bar(stat = 'identity', position = "dodge", colour="black") + labs(fill = "GROUP") + labs(x = NULL, y = NULL, title = "*OUT OF*") + scale_f

我使用GGPLOT和

ggplot(MyDF, aes(x=type, y=count, fill=type)) +
  geom_bar(stat = 'identity', position = "dodge", colour="black") +
  labs(fill = "GROUP") +
  labs(x = NULL, y = NULL, title = "*OUT OF*") +
  scale_fill_manual(values=c("darkseagreen5","darkseagreen","darkseagreen4",
                             "indianred3","indianred1"),
                    labels = c("SCORE<10 & SCORE2<7",
                               "IMPV >= 55%",
                               "IMPV >= 35%",
                               "SCORE>17 OR SCORE2>14 OR IMPV<22%",
                               "BDI OR SCORE>SCORE2"))+
  geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
  geom_text(aes(label = count_n), position = position_dodge(0.9), 
            vjust=-0.3, colour = "black", size=4.6) +
  scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))

ggplot(MyDF,aes(x=type,y=count,fill=type))+
几何图形栏(stat='identity',position=“dodge”,color=“black”)+
实验室(fill=“集团”)+
实验室(x=NULL,y=NULL,title=“*共*”)+
比例填充手动(值=c(“暗绿色5”、“暗绿色”、“暗绿色4”),
“indianred3”、“indianred1”),
标签=c(“分数=35%”,
“分数>17或分数2>14或分数2”))+
几何图形文本(aes(y=0,标签=count_per),大小=5,vjust=-0.6,微移y=.2)+
几何图形文字(aes(标签=计数),位置=位置减淡(0.9),
vjust=-0.3,color=“black”,size=4.6)+
刻度连续(限值=c(0,30),断点=seq(0,30,by=5))
我想调整右边标签窗口(组)的空格和字体(例如加粗)。 我无法调整字体/大小/间距等。。。 你能帮我吗,我的目标是创建一个小标题,例如:

非\u响应:

尝试以下方法:

#Code
ggplot(MyDF, aes(x=type, y=count, fill=type)) +
  geom_bar(stat = 'identity', position = "dodge", colour="black") +
  labs(fill = "GROUP") +
  labs(x = NULL, y = NULL, title = "*OUT OF 55 PATIENTS") +
  scale_fill_manual(values=c("darkseagreen1","darkseagreen","darkseagreen4",
                             "indianred3","indianred1"),
                    labels = c("BDI<10 & HAM<7",
                               "IMPV >= 50%",
                               "IMPV >= 30%",
                               "BDI>17 OR HAM>14 OR IMPV<20%",
                               "BDI OR HAM Post>Pre"))+
  geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
  geom_text(aes(label = count_n), position = position_dodge(0.9), 
            vjust=-0.3, colour = "black", size=4.6) +
  scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))+
  theme(legend.text = element_text(face = 'bold'),
        legend.title = element_text(face = 'bold'))

它的工作,现在让我们说,我只想加粗文本的一部分?那在他们之间制造一个缺口呢?我的目标是让它成为每个小组的一个标题。例如“恶化:BDI OT HAM Post>Pre”,并且只有恶化的粗体字在例如case中,我们应该使用
ggtext
package。让我为您添加一个示例,同时安装该软件包。我添加了一个更新,请安装该软件包,并让我知道这是否适用于您!工作!非常感谢你。有没有办法制造差距?这样“恶化”一词就不会与下一个词在同一行了?是的,我已经用你想要的更新了上一个代码。让我知道这是否有效:)
library(ggtext)
#Code 2
ggplot(MyDF, aes(x=type, y=count, fill=type)) +
  geom_bar(stat = 'identity', position = "dodge", colour="black") +
  labs(fill = "GROUP") +
  labs(x = NULL, y = NULL, title = "*OUT OF 55 PATIENTS") +
  scale_fill_manual(values=c("darkseagreen1","darkseagreen","darkseagreen4",
                             "indianred3","indianred1"),
                    labels = c("**WORSENED:**<br>BDI OT HAM Post>Pre",
                               "IMPV >= 50%",
                               "IMPV >= 30%",
                               "BDI>17 OR HAM>14 OR IMPV<20%",
                               "BDI OR HAM Post>Pre"))+
  geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
  geom_text(aes(label = count_n), position = position_dodge(0.9), 
            vjust=-0.3, colour = "black", size=4.6) +
  scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))+
  theme(legend.text = element_markdown(),
        legend.title = element_text(face = 'bold'))