删除ggplot轴标签中斜体周围的间距

时间:2018-09-13 18:20:00

标签: r ggplot2

我正在复制以下情节。但是,当我将标签中的n斜体化时,它会在其后添加空格。如何控制斜体之间的间距?这是该代码的最低版本:

ggplot(data.frame()) + 
    labs(labs(x=expression("Proportion of "~italic(n)-"gram Model (1-"*gamma*")")))

这是实际的情节:

enter image description here

完整代码(数据太大,无法发布):

ggplot(all_pplx, aes(x=(1-Weight), y=perplexity_val)) +
  geom_line(aes(color=`n-gram`)) +
  scale_y_log10() +
  # scale_x_reverse() +
  labs(title="",
       x=expression("Proportion of "~italic("n")-"gram Model ("*gamma*")"),
       y="Perplexity") +
  theme(axis.text.x = element_text(size=12),
        axis.text.y = element_text(hjust = 1, size=12),
        axis.title.x = element_text(size=12,face="bold"),
        axis.title.y = element_text(size=12),
        plot.title = element_text(hjust = 0.5, size=12),
        legend.position = c(0.15, 0.7), 
        legend.background = element_rect(color = "black", 
                                         fill = "grey90", 
                                         size = .2, 
                                         linetype = "solid")) +
  ggsave('emnlp_new-exp1.pdf', device='pdf')

0 个答案:

没有答案