Skip to content

Column size calculation needs to be user adjustable. #113

@Erotemic

Description

@Erotemic

It looks like there are some heuristics in the code that computes column sizes when rendering the HTML to an image. The following MWE shows the issue I'm running into:

import dataframe_image as dfi
import pandas as pd

text = '{"Eval 21":{"pipe":"BAS+SC","bas_pxl.model.channels":"(L8,PD,S2,WV):BGR","bas_pxl.package_fpath":"Drop8_Median10GSD_allsensors_<tuned>_V7_epoch187_step2632","bas_poly.thresh":0.35,"bas_poly.time_thresh":0.8},"Eval 21b":{"pipe":"BAS","bas_pxl.model.channels":"(L8,PD,S2,WV):BGR","bas_pxl.package_fpath":"Drop8_ARA_Median10GSD_allsensors_pointannsv1_v1_epoch56_step4788","bas_poly.thresh":0.39,"bas_poly.time_thresh":0.75}}'
df = pd.read_json(text)
fpath = 'foo.png'
dfi.export(
    df.style,
    fpath,
    table_conversion='matplotlib',
    fontsize=12,
    max_rows=-1,
    dpi=None,
)
import subprocess
subprocess.call(f'eog {fpath}', shell=True)

This results in a column being cutoff:

foo

If I mess with the fontsize I can get it to work reasonably well. But it would be nicer to either fix the heuristics to work in this case (which may not be possible, I've glanced at them, but haven't seen if they attempt to always well-size the columns), or give the user some means to adjust the multiplier used on each column or something like that.

I'd like to put in a fix for this, but I need feedback on what the right API should be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions