Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

add graphical matrix formatting for score, dynamic programming, and traceback matrices #74

Closed
gregcaporaso opened this issue Feb 3, 2015 · 2 comments

Comments

@gregcaporaso
Copy link
Member

this could use seaborn heatmaps, e.g. where high values get darker colors.

related to #73

@gregcaporaso
Copy link
Member Author

The tabular module works for this, but it seems limited in its customizability.

from tabulate import tabulate
from IPython.core.display import HTML


def format_matrix(row_headers, col_headers, data, hide_zeros=False, cell_width=3, nonzero_val=None):
    rows = []
    for h, d in zip(str(col_headers), data):
        current_row = [h]
        for e in d:
            if e == 0:
                if hide_zeros:
                    current_row.append('')
                else:
                    current_row.append(0)
            else:
                if nonzero_val is not None:
                    current_row.append(nonzero_val)
                else:
                    current_row.append(e)
        rows.append(current_row)
    return tabulate(rows, headers=row_headers, tablefmt='html')

screenshot 2015-12-13 07 47 49

screenshot 2015-12-13 07 47 57

@gregcaporaso
Copy link
Member Author

Fixed using tabular for now - it works, but still leaves something to be desired.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant