JasonKessler / scattertext

Beautiful visualizations of how language differs among document types.
Apache License 2.0
2.23k stars 287 forks source link

Feat: scattertext_structure to matplotlib support #117

Closed ckjellson closed 1 year ago

ckjellson commented 1 year ago

Hi,

I was wanting to use this great package with matplotlib to customize plots and due to problems with slow html rendering, so I added support for exporting the ScattertextStructure to matplotlib. I did this by creating my own package for allocating text-boxes in matplotlib plots (https://github.com/ckjellson/textalloc).

I am not sure if this is anything you or anyone else wants, but since I made an implementation I thought I would make this pull request. If you want this feature but don’t want the additional dependency I could import the relevant code from textalloc, otherwise feel free to remove this PR 😊

output

JasonKessler commented 1 year ago

Thanks so much for putting this together, and this looks really cool.

I'm going to merge this but will remove the new package dependencies and, if textalloc or matplotlib are not present, raise an informative exception when pyplot_from_scattertext_structure is called. The reason for doing this is to minimize the number of dependencies needed when installing Scattertext.

ckjellson commented 1 year ago

No problem, sounds good! Then you should probably add "textalloc==0.0.2" in the info-exception so that there are no clashes if I make an update to the package.

ckjellson commented 1 year ago

I take that back, I meant "textalloc==0.0.3"!