<jupyter_start><jupyter_text>Matplotlib has a Table class that makes a reasonable simulacrum.However, it doesn't allow you to highlight the text (meaning no ctrl-c + ctrl-v), the SVG file is a lot busier because it uses ``s to describe the text instead of ``, and I can't figure out how to remove the vertical white lines between cells. Still, it's the fastest/easiest option.<jupyter_code>import pandas as pd

df = pd.read_csv('https://gist.githubusercontent.com/netj/8836201/raw/6f9306ad21398ea43cba4f7d537619d0e07d5ae3/iris.csv')
df = df.iloc[:10]
import numpy as np
import matplotlib.pyplot as plt
def render_mpl_table(data, col_width=3.0, row_height=0.625, font_size=14, edges='horizontal',
                     header_color='#fff', row_colors=['w', '#eee'], edge_color='w',
                     bbox=[0, 0, 1, 1], header_columns=0,
                     ax=None, **kwargs):
    if ax is None:
        size = (np.array(data.shape[::-1]) + np.array([0, 1])) * np.array([col_width, row_height])
        fig, ax = plt.subplots(figsize=size)
        ax.axis('off')
    mpl_table = ax.table(cellText=data.values, 
                         bbox=bbox, 
                         colLabels=data.columns,
                         #edges=edges,
                         **kwargs)
    mpl_table.auto_set_font_size(False)
    mpl_table.set_fontsize(font_size)

    for k, cell in mpl_table._cells.items():
        cell.set_edgecolor(edge_color)
        if k[0] == 0 or k[1] < header_columns:
            cell.set_text_props(weight='bold', color='black')
            cell.set_facecolor(header_color)
        else:
            cell.set_facecolor(row_colors[k[0]%len(row_colors) ])
    return ax.get_figure(), ax

fig,ax = render_mpl_table(df, header_columns=0, col_width=2.0)

plt.plot([0,1],[1-1/(df.shape[0]+1),1-1/(df.shape[0]+1)], c='black', lw=0.5)
plt.xlim(0,1)
plt.ylim(0,1)
plt.savefig('svg_matplotlib.svg')
from IPython.display import SVG
s = open('svg_matplotlib.svg').read()
SVG(s)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1365441906653426, 'fraction_numerical': 0.03624627606752731, 'mean_word_length': 3.0543259557344062, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '447882', 'license': 'MIT', 'n_tokens_mistral': 761, 'n_tokens_neox': 711, 'n_words': 150, 'path': 'code/write_svg_matplotlib.ipynb', 'repo_name': 'ljmartin/df_to_svg', 'size': '2014'}