def string_to_dict(s):
    """
    Convert a string to a dictionary, with extra processing for some
    matplotlib keyword arguments which are expected to have integer or
    floating point values.

    This function is in ``utils.py``.
    """
    arr = s.split(',')
    dct = {}
    skip = 0
    if len(s) == 0:
        return dct
    for i in range(0, len(arr)):
        if skip > 0:
            skip = skip - 1
        else:
            arr2 = arr[i].split('=')
            if arr2[1][0] == "'" and arr2[1][len(arr2[1]) - 1] == "'":
                arr2[1] = arr2[1][1:len(arr2[1]) - 1]
            if arr2[1][0] == '"' and arr2[1][len(arr2[1]) - 1] == '"':
                arr2[1] = arr2[1][1:len(arr2[1]) - 1]
            if arr2[0] == 'arrowstyle':
                for j in range(0, len(arr)):
                    if arr[j].split('=')[0] == 'head_width':
                        arr2[1] = arr2[1] + ',head_width=' + arr[j].split('=')[
                            1]
                    if arr[j].split('=')[0] == 'head_length':
                        arr2[1] = arr2[1] + ',head_length=' + arr[j].split('='
                            )[1]
                    if arr[j].split('=')[0] == 'tail_width':
                        arr2[1] = arr2[1] + ',tail_width=' + arr[j].split('=')[
                            1]
                    if arr[j].split('=')[0] == 'shrink_factor':
                        arr2[1] = arr2[1] + ',shrink_factor=' + arr[j].split(
                            '=')[1]
                    if arr[j].split('=')[0] == 'widthA':
                        arr2[1] = arr2[1] + ',widthA=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'widthB':
                        arr2[1] = arr2[1] + ',widthB=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'lengthB':
                        arr2[1] = arr2[1] + ',lengthB=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'as_angleB':
                        arr2[1] = arr2[1] + ',angleB=' + arr[j].split('=')[1]
                print('Found arrowstyle option, reprocessed:', arr2[1])
            if arr2[0] == 'connectionstyle':
                for j in range(0, len(arr)):
                    if arr[j].split('=')[0] == 'angleA':
                        arr2[1] = arr2[1] + ',angleA=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'cs_angleB':
                        arr2[1] = arr2[1] + ',angleB=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'armA':
                        arr2[1] = arr2[1] + ',armA=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'armB':
                        arr2[1] = arr2[1] + ',armB=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'rad':
                        arr2[1] = arr2[1] + ',rad=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'fraction':
                        arr2[1] = arr2[1] + ',fraction=' + arr[j].split('=')[1]
                    if arr[j].split('=')[0] == 'angle':
                        arr2[1] = arr2[1] + ',angle=' + arr[j].split('=')[1]
                print('Found connectionstyle option, reprocessed:', arr2[1])
            if arr2[0] == 'zorder':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'lw':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'alpha':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'shrinkA':
                arr2[1] = int(arr2[1])
            if arr2[0] == 'shrinkB':
                arr2[1] = int(arr2[1])
            if arr2[0] == 'bins':
                arr2[1] = int(arr2[1])
            if arr2[0] == 'fig_size_x':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'fig_size_y':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'left_margin':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'right_margin':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'top_margin':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'bottom_margin':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'left':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'right':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'top':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'bottom':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'wspace':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'hspace':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'fontsize':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'font':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'scale':
                arr2[1] = float(arr2[1])
            if arr2[0] == 'sharex':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'reorient':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'sharey':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'squeeze':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'fill':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'ticks_in':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'rt_ticks':
                if arr2[1] == 'True':
                    arr2[1] = True
                else:
                    arr2[1] = False
            if arr2[0] == 'color' and arr[i][5] == '=' and arr[i][6] == '(':
                arr2[1] = arr2[1] + ',' + arr[i + 1] + ',' + arr[i + 2]
                print(arr2[1])
                skip = 2
                arr2[1] = arr2[1][1:len(arr2[1]) - 1]
                arr3 = arr2[1].split(',')
                arr2[1] = float(arr3[0]), float(arr3[1]), float(arr3[2])
            elif arr2[0] == 'color' and arr[i][5] == '=' and arr[i][6] == '[':
                arr2[1] = arr2[1] + ',' + arr[i + 1] + ',' + arr[i + 2
                    ] + ',' + arr[i + 3]
                print(arr2[1])
                skip = 3
                arr2[1] = arr2[1][1:len(arr2[1]) - 1]
                arr3 = arr2[1].split(',')
                arr2[1] = [float(arr3[0]), float(arr3[1]), float(arr3[2]),
                    float(arr3[3])]
            if arr2[0] != 'head_width' and arr2[0] != 'head_length' and arr2[0
                ] != 'tail_width' and arr2[0] != 'rad' and arr2[0
                ] != 'angleA' and arr2[0] != 'as_angleB' and arr2[0
                ] != 'armA' and arr2[0] != 'armB' and arr2[0
                ] != 'angle' and arr2[0] != 'fraction' and arr2[0
                ] != 'shrink_factor' and arr2[0] != 'widthA' and arr2[0
                ] != 'lengthB' and arr2[0] != 'widthB' and arr2[0
                ] != 'cs_angleB':
                dct[arr2[0]] = arr2[1]
    return dct
