2

I am trying to create a grouped bar chart using plotnine ggplot.

bar graph

As you can see the x tick marks are too close to each other and the labels are cluttered. How can I increase the distance between these tick labels?

ggplot(test, aes(x = 'genre_pairs', y = 'average_rating', fill = 'group')) 
+geom_bar(stat = "identity", position = position_dodge()) 
+scale_x_discrete (expand = np.array([0.2,0]))

is what I have so far

Mark
  • 934
  • 1
  • 10
  • 25
Skywind555
  • 31
  • 1
  • 7

2 Answers2

3

You need to make the plot wider by specifying the right figure size. You may find it helpful to rotate the text.

... + theme(figure_size=(11, 6), axis_text_x=element_text(rotation=45)
has2k1
  • 2,095
  • 18
  • 16
0

you can also rotate text directions by using theme(axis_text_x=element_text(angle=30, hjust=1, vjust=1)). For any occasion like this you can use it to discern x tick labels.