プログラミング

pyTable Documentation

pytable

PyTable

 - last update:2020.05.14 ... pytab ver. 1.0.1 -  [Japanese documentation]

PyTable is a tool to plot a table easily.

In this article, the ways to use pyTable and what you can do are written.

This is an official documentation of pyTable.

Installation

source (Github) : HiroshiARAKI/pytable: pytable is the library to plot table easily.

PyPI : pytab · PyPI

Basically usage

PyTable is worked on matplotlib, and pyTable is just wrapped library to use that easily.

As below, you can create a table by passing data as a dict variable.

Now, the dict variable is used as a column data of a table.

pyTable1

Create "rows"

You can add a header of row data in the left side of a table.

pyTable

Change background colors

When you want to change background colors of a header of a table, you solve that by passing color names or color codes to th_c  or td_c.

pyTable

Color names are same to matplotlib's.

pytable-color

pytable-color

pytable-color

(参照:List of named colors – Matplotlib 3.1.0 documentation)

Change design of table cells

Also, you can change table cells to simple and attractive design ones by using table_type.

striped

pytable

dark

pyTable

light

pyTable



Change design of a table header

To only change the colors of a table header attracts people.

At this time, you need pass a design name to th_type.

dark

pyTable

gray

pyTable

light

pyTable

sky

pyTable

Others

In addition,   'blue' , 'red' , 'green' , 'orange'  are available.

And, you can assign the color names or color codes to the background color ( th_face)  and a text color ( th_text), respectively.

pyTable

Other args introduction

The function table() has some options you can use, besides that.

data_loc, th_loc, td_loc

The locations of cell data, a header (columns) and rows are adjustable.

Normally, they are set to right align, center align and center align, respectively, and you can assign them to   'left' , 'center' or  'right'.

figsize

You set the size of a figure by figsize , and need assign that as Tuple[float, float].

Normally, it is set to (3, 3), but this is for a small table.

So, in the case that you create bigger table, you need adjust this argument to make it look good.

It is fine to set to None and adjust it by show().

edge

This is an argument about the edges of a table.

Normally, this is set to 'closed', but you can also use ['open', 'closed', 'horizontal', 'vertical'].

They mean All edges are invisible, All edges are visible, Only horizontal edges are visible and Only vertical edges  are visible, respectively.

If you use options except   'closed', you cannot change a background colors.

Tips about significant digits

When you create a table using experimental results, you may be careful about significant digits.

At such time, you translate data to str before creating a table.

Before modification

pyTable

After modification

pyTable


スポンサードリンク