qiskit/visualization/interactive/iplot_histogram.py
def process_data(data, number_to_keep):
    """ Prepare received data for representation.

        Args:
            data (dict): values to represent (ex. {'001' : 130})
            number_to_keep (int): number of elements to show individually.

        Returns:
            dict: processed data to show.
    """

    result = dict()

    if number_to_keep != 0:
        data_temp = dict(Counter(data).most_common(number_to_keep))
        data_temp['rest'] = sum(data.values()) - sum(data_temp.values())
        data = data_temp

    labels = data
    values = np.array([data[key] for key in labels], dtype=float)
    pvalues = values / sum(values)
    for position, label in enumerate(labels):
        result[label] = round(pvalues[position], 5)

    return result
def process_data(data, number_to_keep):
    result = dict()

    if number_to_keep != 0:
        data_temp = dict(Counter(data).most_common(number_to_keep))
        data_temp['rest'] = sum(data.values()) - sum(data_temp.values())
        data = data_temp

    labels = data
    values = np.array([data[key] for key in labels], dtype=float)
    pvalues = values / sum(values)
    for position, label in enumerate(labels):
        result[label] = round(pvalues[position], 5)

    return result
def process_data ( data , number_to_keep ) : result = dict ( ) if number_to_keep != 0 : data_temp = dict ( Counter ( data ) . most_common ( number_to_keep ) ) data_temp [ 'rest' ] = sum ( data . values ( ) ) - sum ( data_temp . values ( ) ) data = data_temp labels = data values = np . array ( [ data [ key ] for key in labels ] , dtype = float ) pvalues = values / sum ( values ) for position , label in enumerate ( labels ) : result [ label ] = round ( pvalues [ position ] , 5 ) return result
Prepare received data for representation.

        Args:
            data (dict): values to represent (ex. {'001' : 130})
            number_to_keep (int): number of elements to show individually.

        Returns:
            dict: processed data to show.
Prepare received data for representation .