def _draw_rectangle(data, obj, draw_options):
    """Return the PGFPlots code for rectangles.
    """
    label = obj.get_label()
    if label == '':
        return data, []
    handles, labels = obj.axes.get_legend_handles_labels()
    labelsFound = [label for h, label in zip(handles, labels) if obj in h.
        get_children()]
    if len(labelsFound) == 1:
        label = labelsFound[0]
    left_lower_x = obj.get_x()
    left_lower_y = obj.get_y()
    ff = data['float format']
    do = ','.join(draw_options)
    right_upper_x = left_lower_x + obj.get_width()
    right_upper_y = left_lower_y + obj.get_height()
    cont = f"""\\draw[{do}] (axis cs:{left_lower_x:{ff}},{left_lower_y:{ff}}) rectangle (axis cs:{right_upper_x:{ff}},{right_upper_y:{ff}});
"""
    if label != '_nolegend_' and label not in data['rectangle_legends']:
        data['rectangle_legends'].add(label)
        cont += '\\addlegendimage{{ybar,ybar legend,{}}};\n'.format(','.
            join(draw_options))
        cont += f'\\addlegendentry{{{label}}}\n\n'
    return data, cont
