-3

I have a ggplot with on the x-scale the numbers from 0 to 21. I want the numbers 0,4,6,9,12,16,18 and 21 in bold, the rest has to stay like it is normal (grey, not bold)

How do I do that?

4

1 回答 1

1

这是一个例子:

labels <- 1:5
highlight <- c(1, 3, 5)
ggplot(data.frame(x=1:5, y=1:5), aes(x=x, y=y)) + 
  geom_point() + 
  theme(axis.text.x=
          element_text(face=ifelse(labels %in% highlight, "bold", "plain"), 
                      colour=ifelse(labels %in% highlight, "blue", "grey50"), size=25))

在此处输入图像描述

于 2014-07-14T09:06:50.230 回答