Stone-Soup icon indicating copy to clipboard operation
Stone-Soup copied to clipboard

SIAP Metrics Table

Open apiszcz opened this issue 3 years ago • 7 comments

The SIAP metrics table works fine in the example Metrics python notebook. I am interested in saving the table to a png file. When I try this I am only seeing a part of a single row. An HTML output option might be useful in some cases.

siap

apiszcz avatar Jul 02 '21 14:07 apiszcz

This is a common issue with matplotlib, often cutting off annotations and tables, etc. Addding bbox_inches='tight' to the savefig arguments should resolve it.

As this is image generated in matplotlib currently, it wouldn't be possible to create HTML. You could do something like embed as data URI like suggested in this answer on StackOverflow.

sdhiscocks avatar Jul 05 '21 11:07 sdhiscocks

Thank you for the response.

bbox_inches='tight' produces the following output from plt.savefig('test3.png',bbox_inches='tight'). This is better but not complete.

test3

apiszcz avatar Jul 05 '21 11:07 apiszcz

Interesting.

Does this work?

table = SIAPTableGenerator(...).compute_metric()
table.figure.savefig('test.png',  bbox_inches='tight')

sdhiscocks avatar Jul 05 '21 11:07 sdhiscocks

No. I tried this also (Pdb) plt.tight_layout() :1: UserWarning: Tight layout not applied. The bottom and top margins cannot be made large enough to accommodate all axes decorations.

Test st.figure.savefig('test4.png',bbox_inches='tight')

test4

apiszcz avatar Jul 05 '21 14:07 apiszcz

I've just opened a PR that will hopefully scale the figure size better.

I'm not sure why the text is missing in your plot?

sdhiscocks avatar Jul 05 '21 15:07 sdhiscocks

I pulled the latest SS from the repo.. Next I made the PR changes to metrictables.py, still same behavior on my end. Note it is fine (correct plot) in Jupyter Notebook. Saving to a png file is the challenge.

apiszcz avatar Jul 05 '21 16:07 apiszcz

What version of matplotlib are you using?

sdhiscocks avatar Jul 06 '21 07:07 sdhiscocks