0

I'm trying to create the following chart with 4 groups of 3 series.

enter image description here

Notes that each series (red, yellow, blue) has a stacked dotted outline.

So far I have gotten the groups working but don't know how to add a stack on each one: enter image description here

This is my code:

def generate_plots():
    
    labels = ['2000', '2001', '2002', '2003']
    series1 = [1, 2, 3, 4]
    series2 = [4, 5, 7, 3]
    series3 = [6, 7, 4, 2]

    x = np.arange(len(labels))  # the label locations
    width = 0.35  # the width of the bars

    fig, ax = plt.subplots()
    rects1 = ax.bar(x - width/2, series1, width/2, color=[250/255, 10/255, 0])
    rects2 = ax.bar(x, series2, width/2,           color=[250/255, 175/255, 52/255])
    rects3 = ax.bar(x + width/2, series3, width/2, color=[63/255,  72/255,  233/255])

    # Add some text for labels, title and custom x-axis tick labels, etc.
    ax.set_ylabel('Count')
    # ax.set_title('Scores by group and gender')
    ax.set_xticks(x)
    ax.set_xticklabels(labels)
    ax.legend()

    fig.tight_layout()
    plt.savefig('figure.png')
    plt.close()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
nickponline
  • 25,354
  • 32
  • 99
  • 167

0 Answers0