[Matplotlib-users] table in a figure

Diego Avesani diego.avesani at gmail.com
Sun Sep 23 15:07:16 EDT 2018


Dear all,

I have a scrip that put a table in a subfigure.
It works well.
However, if I change the data it seems to not work anymore.
I would try to explain myself in a better way

this is the script:

def latex_table(celldata,rowlabel,collabel):
    table = r'\begin{table} \begin{tabular}{|1|'
    for c in range(0,len(collabel)):
        # add additional columns
        table += r'1|'
    table += r'} \hline'
    # provide the column headers
    for c in range(0,len(collabel)-1):
        table += collabel[c]
        table += r'&'
    table += collabel[-1]
    table += r'\\ \hline'

    # populate the table:
    # this assumes the format to be celldata[index of rows][index of
columns]
    for r in range(0,len(rowlabel)):
        table += rowlabel[r]
        table += r'&'
        for c in range(0,len(collabel)-2):
            if not isinstance(celldata[r][c], basestring):
                table += str(celldata[r][c])
            else:
                table += celldata[r][c]
            table += r'&'

        if not isinstance(celldata[r][-1], basestring):
            table += str(celldata[r][-1])
        else:
            table += celldata[r][-1]
        table += r'\\ \hline'

    table += r'\end{tabular} \end{table}'

    return table

celldata = [[32, r'$\alpha$', 123],[200, 321, 50]]
rowlabel = [r'1st row', r'2nd row']
collabel = [r' sasas', r'$\alpha$', r'$\beta$', r'$\gamma$']


If I read instead "collabel" as
per_data=np.genfromtxt('2.csv',delimiter=',',names=True)
collabel = per_data.dtype.names

It does not print some values in collabel

Can anyone help me?
Really Really Thanks,

Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180923/fb883c5c/attachment.html>


More information about the Matplotlib-users mailing list