How to get a well-scaled table in python using matplotlib
<p>I have been trying to present a table of data in python. I've been generating the table using the matplotlib pyplot module. Unfortunately the data sets I want to present are quite large. Hence when the table displays I either get it showing the entire table, but the data is too tiny to read, or it shows the data at readable size, but cuts off the rest of the table.</p>

<p>My first thought was perhaps if I got the table formatted in a readable way I could then use standard pan/zoom button in the interactive navigation. However clicking and dragging around the screen doesn't seem to shift the table at all. I have tried this on pycharm and anaconda, just in case it made a difference for some reason.</p>

<p>Thus I am wondering, once I  format the table in a readable way, how can I pan around the table? Otherwise, are there any other ways to present large amounts of data in tables using python?</p>

<p>Also please note that I want the table to be shown when the code is executed, not saved as an image.</p>

<p>Some test code I have been working with trying to solve this issue:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

data=np.random.rand(100, 1)
cols=("column")
nrows, ncols = len(data)+1, len(cols)
hcell = 0.2
wcell = 1.0
hpad, wpad = 0, 0
fig=plt.figure(figsize=(ncols*wcell+wpad, nrows*hcell+hpad))
ax =fig.add_subplot(111)
ax.axis('off')
cellText=data
table=ax.table(cellText=cellText, colLabels=cols, loc='cent')
plt.tight_layout()
plt.show()
</code></pre>

<p>Try with Tabulate module, which is very simple to use and support numpy:</p>

<p><a href="https://pypi.python.org/pypi/tabulate" rel="nofollow">tabulate module</a></p>

<p>sample code to start with:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

from tabulate import tabulate
data=np.random.rand(100, 1)

print tabulate(data)
</code></pre>

<p>Using <strong>matplotlib</strong>:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

data = np.random.rand(100, 1)

colLabels=("Fist Column")
nrows, ncols = len(data)+1, len(colLabels)
hcell, wcell = 0.1, 0.1 # tweak as per your requirements
hpad, wpad = 0.5, 0.5    
fig=plt.figure(figsize=(ncols*wcell+wpad, nrows*hcell+hpad))
ax = fig.add_subplot(111)
ax.axis('off')

the_table = ax.table(cellText=data,
          colLabels=colLabels,
          loc='center')

plt.show()
</code></pre>

<p>References:</p>

<ol>
<li><a href="http://stackoverflow.com/a/26937531/2575259">http://stackoverflow.com/a/26937531/2575259</a></li>
<li><a href="http://stackoverflow.com/questions/17232683/creating-tables-in-matplotlib">Creating tables in matplotlib</a></li>
<li><a href="http://stackoverflow.com/questions/3584805/in-matplotlib-what-does-the-argument-mean-in-fig-add-subplot111">In Matplotlib, what does the argument mean in fig.add_subplot(111)?</a></li>
</ol>

python matplotlib formatting