JasonKessler / scattertext

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

Scattertext on multiple category data #57

Closed un-lock-me closed 4 years ago

un-lock-me commented 4 years ago

Can you please have a look at this issue with scattertext?

https://stackoverflow.com/questions/61327317/text-visualization-using-scattertext-for-multiple-category

I appreciate it.

JasonKessler commented 4 years ago

I replied in the stackoverflow thread.

Here it is, verbatim.

I recommend you either create a series of one-vs-rest Scattertext plots comparing each category to all others, and/or make a set of one-vs-one comparing each category to each other category separately.

Then, build HTML scaffolding around the set of plots to enable users to select the categories they'd want to compare.

You can see an example of it in https://github.com/JasonKessler/acl17-handbook/blob/master/scattertext-analysis/Scattertext-Analysis.ipynb

MastafaF commented 3 years ago

Hey @JasonKessler ,

What about building an html which embedding several 1vs1 graphs either side by side or down each other? I would be interested in comparing say different cities. Therefore an interesting view would be several graphs with city1 vs city2, city1 vs city3, ..., city1 vs cityN.

One could then click on any of those graphs and then get further insights like the classical view we have on scattertext currently. Would that be something too difficult to implement? Happy to help here. 😄

In summary, that would be a scenario where we would have:

  1. Several clickable graphs comparing 1v1
  2. Each graph once clicked would lead to the usual view we have on scattertext
MastafaF commented 3 years ago

At this stage, I am building several html files and appending them to a common file. However, there are issues in the rendering. For example, all the search boxes appear at the end of the page and when clicking a point of a given graph, the list of mentions would appear at the very end of the page when we would expect it to appear just at the bottom of the selected graph.

More precisely, for each 1v1 comparison, I build the html like usual and then append it to the common file. In other words, the final html is the concatenation (one after another) of the html files obtained after 1v1 comparison.

JasonKessler commented 3 years ago

I encourage you to take a look at the codebase and see if you can fix some of these UI issues. It should be pretty straight forward to build an extension to let a user look at a number of 1v1 comparisons.

Best of luck if you choose to write any of these extensions, and I'm happy to review PRs.

MastafaF commented 3 years ago

Thanks for the suggestion @JasonKessler. I can take a look at it.

Which source file/files would you focus on for this extension?

JasonKessler commented 3 years ago

I'd look at the notebook linked above for an example on how to pick from multiple charts, each one-vs-all.

If you'd like to change any of the rendering or the javascript, I'd look at main.js and scattertext.html in data/viz/.

Best of luck!