0

I am trying to bold some of the name in the x-axis. For example,

fruits = c("apple", "orange", "watermelons")
juice_content = c(10, 1, 1000)
weight = c(5, 2, 2000)
df = data.frame(fruits, juice_content, weight)
df = gather(df, compare, measure, juice_content:weight, factor_key=TRUE)
plot = ggplot(df, aes(fruits, measure, fill = compare)) + 
         geom_bar(stat = "identity", position = position_dodge())

I want the label orange be bold in the x-axis.

Edit. With the helps from the comment, I am able to get the x-axis bolded. However, I am not able to compare the two lists.

Here we have fruits = c("apple", "orange", "watermelons")

let's say that this list has become longer: fruits = c("apple", "orange", "watermelons","pears","banana","mango")and we have another shorter list of fruits list: short_fruit=c("orange","apple","mango")

How can I compare them?

I tried vec_fontface <- ifelse(fruit == short_fruit,"bold","plain") but it doesn't seems to work.

Johnny Ton
  • 87
  • 6
  • I think you want to check [this question](https://stackoverflow.com/questions/47223150/mark-certain-axis-text-in-bold). – jazzurro Oct 28 '19 at 02:21
  • @JohnnyTon I was at work and I could not see your comment till now. Let me clarify what you want. Do you want orange, apple, and mango in bold font? If not, can you tell us what you are after clearly. – jazzurro Oct 28 '19 at 13:34
  • @jazzurro yes! But I want the code to be more general, like with respect to the whole list rather than something like : `vec_fontface <- ifelse(fruit == c("orange","apple","mango") ,"bold","plain")` – Johnny Ton Oct 28 '19 at 15:19
  • @JohnnyTon By saying "more general", what do you mean? Isn't `vec_fontface <- ifelse(fruit %in% c("orange","apple","mango") ,"bold","plain")` enough? – jazzurro Oct 28 '19 at 22:13

0 Answers0