import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,2.5))

#1
cpalette = {'Foreground': '#d97859', 'Background': '#0f8f6f'}

#2
ax.add_patch(Rectangle(xy=(0, 1), width=4, height=4,
             facecolor=cpalette['Background'], edgecolor='dimgrey'))
ax.add_patch(Rectangle(xy=(1, 0), width=4, height=4,
             facecolor=cpalette['Foreground'], edgecolor='dimgrey',
             alpha=1.0))
#3
ax.text(x=2.5, y=-1.0, s='No transparency (\u03B1 = 1.0)', 
        horizontalalignment='center', fontsize='14')

#4
alpha = 0.8
ax.add_patch(Rectangle(xy=(7, 1), width=4, height=4,
             facecolor=cpalette['Background'], edgecolor='dimgrey'))
ax.add_patch(Rectangle(xy=(8, 0), width=4, height=4,
             facecolor=cpalette['Foreground'], edgecolor='dimgrey',
             alpha=alpha))
ax.text(x=9.5, y=-1.0, s=f'\u03B1 = {alpha:2.1f}', 
        horizontalalignment='center', fontsize='14')

#5
alpha = 0.6
ax.add_patch(Rectangle(xy=(14, 1), width=4, height=4,
             facecolor=cpalette['Background'], edgecolor='dimgrey'))
ax.add_patch(Rectangle(xy=(15, 0), width=4, height=4,
             facecolor=cpalette['Foreground'], edgecolor='dimgrey',
             alpha=alpha))
ax.text(x=16.5, y=-1.0, s=f'\u03B1 = {alpha:2.1f}', 
        horizontalalignment='center', fontsize='14')

#6
ax.set_xlim(left=0, right=21)
ax.set_ylim(bottom=0, top=6)

#7
ax.axis('equal')
ax.axis('off')

fig.savefig('charts/transparency.png', bbox_inches='tight', dpi=600)