meaning & purpose of each row # The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 

# dataset = pandas.DataFrame(adtype, Users)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:

# Complete code with reduced height for the bottom-most triangle

import matplotlib.pyplot as plt
import pandas as pd
col1 = ['DSP', 'Sponsored Display', 'Sponsored Products', 'Sponsored Brands']
col2 = [0.6134, 0.2689, 0.0577, 0.0524]
df = pd.DataFrame({'Type': col1, 'Percentage': col2})
df['perc'] = df['Type'] + ' ' + (df['Percentage'] * 100).round(2).astype(str) + '%'
rperc = df['perc'][::-1].reset_index(drop=True)

def draw_upside_down_triangle(base_length):
    # fig, ax = plt.subplots()
    fig, ax = plt.subplots(figsize=(12, 10))  # Increase the canvas size
    plt.subplots_adjust(left=0, right=0.8, top=0.9, bottom=0.1)  # Add more space around the figure
    
    
    # Coordinates for the vertices of the triangle
    x_coords = [0, base_length, base_length / 2]
    y_coords = [(base_length * (3 ** 0.5)) / 2, (base_length * (3 ** 0.5)) / 2, 0]
    
    # Draw the triangle
    ax.fill(x_coords, y_coords, 'b', edgecolor='black')
    
    # Calculate the y-coordinate values for the horizontal lines
    line1_y = base_length * 0.2165
    line2_y = base_length * 0.433
    line3_y = base_length * 0.6495

    
    # Set the length and starting position for each horizontal line
    line_length = base_length
    line1_x_start = base_length * 0.375
    line2_x_start = base_length *  0.25
    line3_x_start = base_length * 0.125

    
    # Draw the horizontal lines accurately
    ax.hlines([line1_y, line2_y, line3_y], xmin=[line1_x_start, line2_x_start, line3_x_start], 
              xmax=[line1_x_start+line_length*0.25, line2_x_start + line_length*0.5, line3_x_start + line_length*0.75],
              color='gray', linewidth=1)


    segments = [
        {'x': [base_length*0.5, line1_x_start, line1_x_start+line_length*0.25],
         'y': [0, line1_y, line1_y],
         'color': '#FDDB98',  # Yellow Gold
         'label': 'Segment 1'},
        
        {'x': [line1_x_start, line1_x_start+line_length*0.25, line2_x_start + line_length*0.5, line2_x_start],
         'y': [line1_y, line1_y, line2_y, line2_y],
         'color': '#EFBF9C',  # Light Salmon
         'label': 'Segment 2'},
        
        {'x': [line2_x_start, line2_x_start+line_length*0.5, line3_x_start + line_length*0.75, line3_x_start],
         'y': [line2_y, line2_y, line3_y, line3_y],
         'color': '#E79F6B',  # Salmon
         'label': 'Segment 3'},
        
        {'x': [line3_x_start, line3_x_start+line_length*0.75, base_length, 0],
         'y': [line3_y, line3_y, base_length*0.866, base_length*0.866],
         'color': '#DF7F39',  # Orange
         'label': 'Segment 4'}
    ]
    
    for idx, segment in enumerate(segments):
        plt.fill(segment['x'], segment['y'], color=segment['color'])
        
        # Calculate approximate center for placing text label
        y_center = sum(segment['y']) / len(segment['y'])
        
        # Place the text outside the triangle on the right-hand side
        plt.text(max(segment['x']) + 0.01, y_center, rperc[idx], fontsize=20, ha='left', va='center')

    
    # ax.set_aspect('equal', 'box')
    plt.axis('off')
    plt.show()

# Draw an upside-down triangle with base length 5 and three horizontal lines
draw_upside_down_triangle(5)