Changing font size and direction of axes text in ggplot2

前端 未结 7 1242
萌比男神i
萌比男神i 2020-11-28 17:37

I am plotting a graph with a categorical variable on the x axis and a numerical variable on the y axis.

For the x axis, given that there are many data points, the de

7条回答
  •  抹茶落季
    2020-11-28 18:17

    Using "fill" attribute helps in cases like this. You can remove the text from axis using element_blank()and show multi color bar chart with a legend. I am plotting a part removal frequency in a repair shop as below

    ggplot(data=df_subset,aes(x=Part,y=Removal_Frequency,fill=Part))+geom_bar(stat="identity")+theme(axis.text.x  = element_blank())
    

    I went for this solution in my case as I had many bars in bar chart and I was not able to find a suitable font size which is both readable and also small enough not to overlap each other.

提交回复
热议问题