Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Delete vertical lines (or vertical rules) in plt.table? How to remove cell boundaries and shows table as scientific tables? #4044

@arnaldorusso

Description

@arnaldorusso

Is there any way to remove the vertical lines in a matplotlib table?
Or even using text.usetex=True obtain a plot (using Arial for all texts and numbers) and append a table without vertical lines?

My code is this:

import matplotlib.pyplot as plt
import seaborn as sns

sns.set_style("ticks")
plt.rcParams.update({'xtick.labelsize' : 9,
                    'ytick.labelsize' : 9,
                    'mathtext.fontset' : 'stixsans',
                    'mathtext.default': 'regular'
                    })

plt.subplots_adjust(left=0.17, right=0.96, top=0.97, bottom=0.09)

fig = plt.figure(figsize=(5.5, 3.4))
ax = fig.add_subplot(111)

ax.plot([1, 2, 3, 4, 5, 6])
ax.set_xlabel('X Label')
ax.set_ylabel('Unit ('+u'μ'+r'velocity $\cdot$ m$^{-2}$ s$^{-1}$)',
             size=10)

l1 = ["","t0", "t1", "t2", "t3 ", "t4", "t5", "t6"]
l2 = ["DLI", 35, 38, 10, 22, 25, 85, 22]
t = ax.table(
            colWidths=[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
            cellText = [l1, l2],
            loc="upper center",
            colLoc="center",
            rowLoc="center",
            )
plt.savefig('mpl_table.png')
plt.show()

I tried to include some LaTeX stuff in another plot, which preserves Arial font, but does not render the table with horizontal lines Table correct. When I get the table as I want, the fonts can not be setted to Arial.

Here the codes show the plots in two steps. First generating the first plot and after running in a new session the second plot.

My main problem is to maintain the Arial font (mandatory rules in the guide for authors) and tables should be without vertical rules, as stated on first plot.

I have here three approachs and no one satisfy those recquirements (e.g. Arial font and table with no vertical lines)

I could not figure it out. Any clues?

Cheers,
Arnaldo.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions