0

I have an R code in the following:

x = c("一名","網民","議員")
y = c(506,526,527)

df <- data.frame(x = x , y = y)
library("ggplot2")
#ggplot(data=df,aes(x=x,y=y)) + geom_bar(stat="identity")

df$x <- factor(df$x,levels=c("一名","網民","議員"))

#p <- ggplot(data=df,aes(x=x,y=y)) + geom_bar(stat="identity",fill='#79FF79', alpha=.6, width =.7) + scale_y_continuous("Count")+scale_x_discrete('Channel') + theme(text = element_text(size=25))
p <- ggplot(data=df,aes(x=x,y=y)) + geom_bar(stat="identity",fill='#79FF79', alpha=.6, width =.7) + scale_y_continuous("Amount")+scale_x_discrete('Words') + theme(text = element_text(size=25))
p <- p + coord_flip()
p <- p+ggtitle("Topics per each channel")
p <- p + labs(title="Top3", x="Amount", y="Words")+  theme(plot.title = element_text(hjust = 0.5),title=element_text(family="myFont",size=35,color="black"))
#theme(plot.title = element_text(hjust=0.5),title=element_text(family="myFont",size=20,color="black"))

ggsave('test.png', plot = p, width = 18, height=13,dpi=300,limitsize = FALSE)

When I need to output the graph, I got the following result.

Result

Then, I hope to adjust the font size of "一名", "網民", and "議員". I got some problems. I don't what to make the font size of "一名", "網民", and "議員" larger in the graph. Can anyone help me? Thanks.

  • 4
    Does this answer your question? [Changing font size and direction of axes text in ggplot2](https://stackoverflow.com/questions/13297995/changing-font-size-and-direction-of-axes-text-in-ggplot2) – Maël Dec 01 '21 at 15:28
  • 2
    I am not sure I understand the question? You want to increase the font size of those labels but you don't want to make the font size of the labels larger in the graph? – neuron Dec 01 '21 at 15:33
  • I want to make the font size in x-axis and y-axisin the labels because the label words is very small, However, I don't know what to make it. – Project Zenbo Dec 02 '21 at 04:12

0 Answers0