utils.py
def plotly_histogram(res, title, ind, pos_group):
    """
    Function used to convert data list to html-ready plotly histogram.
    """
    colors = px.colors.qualitative.Plotly
    primary_key = remove_list_dup([item[0] for item in res.keys()])
    names = remove_list_dup([item[1] for item in res.keys()])
    ys_pos, ys_neg = [], []
    for value in res.values():
        neg_group = list(value.keys())[1-list(value.keys()).index(pos_group)]
        ys_pos.append(value[pos_group])
        ys_neg.append(value[neg_group])
    # ys_pos = [ys_pos[i*len(primary_key):(i + 1) * len(primary_key)] for i in range((len(ys_pos) + len(primary_key) - 1) // len(primary_key))]
    ys_pos = np.array(ys_pos).reshape(2, int(len(ys_pos)/2)).T
    # ys_neg = [ys_neg[i*len(primary_key):(i + 1) * len(primary_key)] for i in range((len(ys_neg) + len(primary_key) - 1) // len(primary_key))]
    ys_neg = np.array(ys_neg).reshape(2, int(len(ys_neg)/2)).T
    if ind:
        bars = [go.Bar(name=name, x=primary_key, y=y, legendgroup=str(i), marker_color = colors[i]) for i, (name,y) in enumerate(zip(names, ys_pos))]
        for i, (name,y) in enumerate(zip(names, ys_neg)):
            bars.append(go.Bar(name = name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]))
    else:
        bars = [go.Bar(name=name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]) for i, (name,y) in enumerate(zip(names, ys_pos))]
        for i, (name,y) in enumerate(zip(names, ys_neg)):
            bars.append(go.Bar(name = name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]))

    return bars, len(ys_pos)

    Function used to convert data list to html-ready plotly histogram.
    
Function used to convert data list to html-ready plotly histogram.
Function used to convert data list to html - ready plotly histogram .
def plotly_histogram(res, title, ind, pos_group):
    colors = px.colors.qualitative.Plotly
    primary_key = remove_list_dup([item[0] for item in res.keys()])
    names = remove_list_dup([item[1] for item in res.keys()])
    ys_pos, ys_neg = [], []
    for value in res.values():
        neg_group = list(value.keys())[1-list(value.keys()).index(pos_group)]
        ys_pos.append(value[pos_group])
        ys_neg.append(value[neg_group])
    ys_pos = np.array(ys_pos).reshape(2, int(len(ys_pos)/2)).T
    ys_neg = np.array(ys_neg).reshape(2, int(len(ys_neg)/2)).T
    if ind:
        bars = [go.Bar(name=name, x=primary_key, y=y, legendgroup=str(i), marker_color = colors[i]) for i, (name,y) in enumerate(zip(names, ys_pos))]
        for i, (name,y) in enumerate(zip(names, ys_neg)):
            bars.append(go.Bar(name = name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]))
    else:
        bars = [go.Bar(name=name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]) for i, (name,y) in enumerate(zip(names, ys_pos))]
        for i, (name,y) in enumerate(zip(names, ys_neg)):
            bars.append(go.Bar(name = name, x=primary_key, y=y, legendgroup=str(i), showlegend=False, marker_color = colors[i]))
    return bars, len(ys_pos)
def plotly_histogram ( res , title , ind , pos_group ) : colors = px . colors . qualitative . Plotly primary_key = remove_list_dup ( [ item [ 0 ] for item in res . keys ( ) ] ) names = remove_list_dup ( [ item [ 1 ] for item in res . keys ( ) ] ) ys_pos , ys_neg = [ ] , [ ] for value in res . values ( ) : neg_group = list ( value . keys ( ) ) [ 1 - list ( value . keys ( ) ) . index ( pos_group ) ] ys_pos . append ( value [ pos_group ] ) ys_neg . append ( value [ neg_group ] ) ys_pos = np . array ( ys_pos ) . reshape ( 2 , int ( len ( ys_pos ) / 2 ) ) . T ys_neg = np . array ( ys_neg ) . reshape ( 2 , int ( len ( ys_neg ) / 2 ) ) . T if ind : bars = [ go . Bar ( name = name , x = primary_key , y = y , legendgroup = str ( i ) , marker_color = colors [ i ] ) for i , ( name , y ) in enumerate ( zip ( names , ys_pos ) ) ] for i , ( name , y ) in enumerate ( zip ( names , ys_neg ) ) : bars . append ( go . Bar ( name = name , x = primary_key , y = y , legendgroup = str ( i ) , showlegend = False , marker_color = colors [ i ] ) ) else : bars = [ go . Bar ( name = name , x = primary_key , y = y , legendgroup = str ( i ) , showlegend = False , marker_color = colors [ i ] ) for i , ( name , y ) in enumerate ( zip ( names , ys_pos ) ) ] for i , ( name , y ) in enumerate ( zip ( names , ys_neg ) ) : bars . append ( go . Bar ( name = name , x = primary_key , y = y , legendgroup = str ( i ) , showlegend = False , marker_color = colors [ i ] ) ) return bars , len ( ys_pos )
Function used to convert data list to html-ready plotly histogram.
Function used to convert data list to html - ready plotly histogram .
"""
    Function used to convert data list to html-ready plotly histogram.
    """ # ys_pos = [ys_pos[i*len(primary_key):(i + 1) * len(primary_key)] for i in range((len(ys_pos) + len(primary_key) - 1) // len(primary_key))] # ys_neg = [ys_neg[i*len(primary_key):(i + 1) * len(primary_key)] for i in range((len(ys_neg) + len(primary_key) - 1) // len(primary_key))]
res
title
ind
pos_group