0

I am trying to plot a barplot using matplotlib with different gap sizes between the bars. I have been reading other posts, but mostly I found that only changing the bar width helps. I was hoping for a different solution.

I have 5 locations with 3 bars each I want to show. That makes 15 bars in total. For each of the locations I am trying to have one tick on the x-Axis with 3 bars without any space in between them. But from those three bars to the next location with 3 bars, I need to have some space in between. I hope you get what I am trying to say.

    plt.bar('A', Data_A, width = 0.5, color='navy', label='A')
    plt.bar('B', Data_B, width = 0.5, color='mediumblue', label='B')
    plt.bar('C', Data_C, width = 0.5, color='brown', label='C')
    plt.bar('D', Data_D, width = 0.5, color='darkred', label='D')
    plt.bar('E', Data_E, width = 0.5, color='salmon', label='E')
    plt.ylabel('RMSE[%]')
    #plt.legend(bbox_to_anchor=(0.04, 1.2), loc='upper left', ncol=3)
    #plt.savefig('Pearson'+name+'.png')
    plt.show()

This is what I used so far, but now I want to exchange each bar with 3 more specific bars, which will make the whole thing very chaotic, if I cant change the gapsize.

Is there a simple way of setting the gapsize between the bars, even if they are all the same width?

Elias
  • 115
  • 1
  • 8
  • 1
    Is it something like [this](https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/barchart.html#grouped-bar-chart-with-labels) that you want? – tomjn Sep 17 '19 at 14:10
  • oops, yes it is. it is exactly what I needed. Thanks. – Elias Sep 17 '19 at 14:28

0 Answers0