[Matplotlib-users] table in a figure
Thomas Caswell
tcaswell at gmail.com
Sun Oct 7 13:15:36 EDT 2018
Diego,
It is hard to say much without also seeing your csv file.
What is the difference between the type and contents of the `collabel` in
both cases?
It looks like the later returns a tuple instead of a list (see
https://docs.scipy.org/doc/numpy-1.15.0/user/basics.rec.html#manipulating-and-displaying-structured-datatypes
).
Tom
On Sun, Sep 23, 2018 at 3:07 PM Diego Avesani <diego.avesani at gmail.com>
wrote:
> 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
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
--
Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20181007/d98a7548/attachment.html>
More information about the Matplotlib-users
mailing list