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?

2
  • 1
    Is it something like this that you want? Commented Sep 17, 2019 at 14:10
  • oops, yes it is. it is exactly what I needed. Thanks. Commented Sep 17, 2019 at 14:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.