How to use the termplotlib.helpers.is_unicode_standard_output function in termplotlib

To help you get started, we’ve selected a few termplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / termplotlib / termplotlib / barh.py View on Github external
def barh(
    vals, labels=None, max_width=40, bar_width=1, show_vals=True, force_ascii=False
):
    matrix = _get_matrix_of_eighths(vals, max_width, bar_width)

    if is_unicode_standard_output() and not force_ascii:
        chars = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"]
    else:
        chars = [" ", "*", "*", "*", "*", "*", "*", "*", "*"]

    fmt = []
    if labels:
        cfmt = "{{:{}s}}".format(max([len(str(label)) for label in labels]))
        fmt.append(cfmt)

    if show_vals:
        all_int = all(val == int(val) for val in vals)
        if all_int:
            cfmt = "{{:{}d}}".format(max([len(str(val)) for val in vals]))
        else:
            cfmt = "{}"
        fmt.append("[" + cfmt + "]")
github nschloe / termplotlib / termplotlib / hist.py View on Github external
for row in matrix:
            if any([item != 0 for item in row]):
                break
            k0 += 1

        k1 = 0
        for row in matrix[::-1]:
            if any([item != 0 for item in row]):
                break
            k1 += 1
        n = len(matrix)
        matrix = matrix[k0 : n - k1]
    else:
        k0 = 0

    if is_unicode_standard_output() and not force_ascii:
        block_chars = [" ", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
        left_seven_eighths = "▉"
    else:
        block_chars = [" ", "*", "*", "*", "*", "*", "*", "*", "*"]
        left_seven_eighths = "*"

    # print text matrix
    out = []
    for row in _flip(matrix):

        # Cut off trailing zeros
        r = _trim_trailing_zeros(row)

        c = [block_chars[item] for item in r]

        # add grid lines