def textplot(cflo):
    """Text plot of a cashflow.

    >>> cflo = cashflow(const_value=[-10, 5, 0, 20] * 3, start='2000Q1', freq='Q')
    >>> textplot(cflo)# doctest: +NORMALIZE_WHITESPACE
    time      value +------------------+------------------+
    2000Q1   -10.00           **********
    2000Q2     5.00                    *****
    2000Q3     0.00                    *
    2000Q4    20.00                    ********************
    2001Q1   -10.00           **********
    2001Q2     5.00                    *****
    2001Q3     0.00                    *
    2001Q4    20.00                    ********************
    2002Q1   -10.00           **********
    2002Q2     5.00                    *****
    2002Q3     0.00                    *
    2002Q4    20.00                    ********************

    """
    timeid = cflo.index.to_series().astype(str)
    len_timeid = len(timeid[-1].__repr__())
    fmt_timeid = '{:<' + '{:d}'.format(len_timeid) + 's}'
    len_number = 0
    for value in cflo:
        len_number = max(len_number, len('{:1.2f}'.format(value)))
    fmt_number = ' {:' + '{:d}'.format(len_number) + '.2f}'
    fmt_header = ' {:>' + '{:d}'.format(len_number) + 's}'
    maxval = max(abs(cflo))
    width = 20
    txt = []
    txtrow = fmt_timeid.format('time') + fmt_header.format('value')
    txtrow += ' +' + '-' * (width - 2) + '+' + '-' * (width - 2) + '+'
    txt.append(txtrow)
    for value, timeid in zip(cflo, cflo.index.to_series().astype(str)):
        txtrow = fmt_timeid.format(timeid.__str__())
        txtrow += fmt_number.format(value)
        xlim = int(width * abs(value / maxval))
        if value < 0:
            txtrow += ' ' + ' ' * (width - xlim) + '*' * xlim
        elif value > 0:
            txtrow += ' ' + ' ' * (width - 1) + '*' * xlim
        else:
            txtrow += ' ' + ' ' * (width - 1) + '*'
        txt.append(txtrow)
    print('\n'.join(txt))
