Giter Club home page Giter Club logo

matplotlib_venn_wordcloud's People

Contributors

jasonschray avatar paulbrodersen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

matplotlib_venn_wordcloud's Issues

Not possible to render this to d3 frontend using mpld3

When I tried rendering this,only the word cloud is displayed.but the circles are not displayed.
Code I have tried:

    fig, ax = plt.subplots(figsize=(10,10))
    ax.set_title('Top 50 Cat and Dog Names in Seattle', fontsize=20)
    v = venn2_wordcloud([set1, set2],
                    ax=ax, set_labels=["year1", "year2"])
    # add color
    v.get_patch_by_id('10').set_color('green')
    v.get_patch_by_id('10').set_alpha(0.4)
    v.get_patch_by_id('01').set_color('blue')
    v.get_patch_by_id('01').set_alpha(0.4)
    v.get_patch_by_id('11').set_color('purple')
    v.get_patch_by_id('11').set_alpha(0.4)
    html_graph = mpld3.fig_to_html(fig)

Handling of border cases

Currently, if the input data is degenerated, i.e., two sets are empty or all intersections are empty etc., the diagram gets messed up. It would really be good to have handling of such cases because they appear quite often in real life.
Should this be fixed in matplotlib_venn_wordcloud or in the parent matplotlib-venn?

How to export higher resolution figure?

This is a great representation of venn diagram analysis! I'm trying to generate a venn diagram with gene names in corresponding sets. The plot I saved in Spyder is tiny and blurry, how can I adjust the size of the plot and/or its resolution?

min and max font sizes

Hi,

I love your concept and I think it is a great tool! I'm struggling with setting minimum and maximum font sizes for the words - is there a way to set it (as in a regular wordcloud)?

Some words missing in the set intersection

Some words are not rendered in the set intersection in my simple example, depending on their frequency. Here's a Google Colab link: https://colab.research.google.com/drive/1H8qTzKh0sgC4RmGAHQbFZwxIuRfcMheb?usp=sharing

Code to reproduce:

from matplotlib_venn_wordcloud import venn2_wordcloud

words_left = {
    "abc": 1,
    "def": 5,
    "qwe": 2,
    "lorem": 1,
}
words_right = {
    "qwe": 3,
    "abc": 1,
    "zxc": 5,
    "ipsum": 1,
}

word_to_frequency={word: words_left.get(word, 0) + words_right.get(word, 0) for word in words_left.keys() | words_right.keys()}
print(word_to_frequency)
venn2_wordcloud([set(words_left), set(words_right)],
                word_to_frequency=word_to_frequency,
)

Results in:
image

The middle section should have "qwe" and "abc", both are missing.

Package versions:

Collecting matplotlib-venn-wordcloud
  Downloading matplotlib_venn_wordcloud-0.2.6-py3-none-any.whl (11 kB)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from matplotlib-venn-wordcloud) (1.25.2)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from matplotlib-venn-wordcloud) (3.7.1)
Requirement already satisfied: matplotlib-venn in /usr/local/lib/python3.10/dist-packages (from matplotlib-venn-wordcloud) (0.11.10)
Requirement already satisfied: wordcloud in /usr/local/lib/python3.10/dist-packages (from matplotlib-venn-wordcloud) (1.9.3)
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (1.2.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (4.49.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (23.2)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (9.4.0)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->matplotlib-venn-wordcloud) (2.8.2)
Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from matplotlib-venn->matplotlib-venn-wordcloud) (1.11.4)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib->matplotlib-venn-wordcloud) (1.16.0)
Installing collected packages: matplotlib-venn-wordcloud
Successfully installed matplotlib-venn-wordcloud-0.2.6

composite words not recognized

Hello,
I am trying to use your lib to make differential analysis for a data science project. I had to make some changes to your code because sometimes sets are empty and for the visualization, venn3_unweighted comes handy (you can check out the fork¹ if you like).
One problem I couldn't solve is that composite words (that wordcloud.WordCloud handles well) are not properly recognized, thus messing the visualization.
As you see here, the article "di" is repeated in different sets:
https://raw.githubusercontent.com/rugantio/Venn/master/images/AndreaSantiagoAntonietta_words.png
I thought that the problem was at line 402 where the main.py says
if not word_to_frequency: text = " ".join(words) wc.generate(text)
I tried to fix it but couldn't do it, can you give a look?
Thank you for your work!

¹ The code I'm using https://github.com/rugantio/matplotlib_venn_wordcloud/blob/master/matplotlib_venn_wordcloud/_main.py

AttributeError: Unknown property axisbg

I installed all the prerequisites on python3.6 and am getting the following error when trying to use the library.

matplotlib versions:

root@thehost:~# pip3 freeze | grep mat
matplotlib==2.2.2
matplotlib-venn==0.11.5
matplotlib-venn-wordcloud==0.2.1


AttributeError Traceback (most recent call last)
in ()
21
22 # create visualisation
---> 23 venn2_wordcloud(sets)

/usr/local/lib/python3.6/dist-packages/matplotlib_venn_wordcloud/_main.py in venn2_wordcloud(sets, set_labels, set_colors, set_edgecolors, alpha, ax, word_to_frequency, wordcloud_kwargs)
186 venn.get_words_by_id = _func
187
--> 188 return _venn_wordcloud(venn, ax, word_to_frequency, **wordcloud_kwargs)
189
190

/usr/local/lib/python3.6/dist-packages/matplotlib_venn_wordcloud/_main.py in _venn_wordcloud(ExtendedVennDiagram, ax, word_to_frequency, **wordcloud_kwargs)
372 img.rgba += wc.to_array() / 255.
373
--> 374 img.imshow(interpolation='bilinear')
375
376 return ExtendedVennDiagram

/usr/local/lib/python3.6/dist-packages/matplotlib_venn_wordcloud/_main.py in imshow(self, **imshow_kwargs)
435 bbox = self.ax.get_position() # in figure coordinates
436 fig = self.ax.get_figure()
--> 437 subax = fig.add_axes(bbox, axisbg=None)
438
439 # plot image

/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py in add_axes(self, *args, **kwargs)
1134
1135 # create the new axes using the axes class given
-> 1136 a = projection_class(self, rect, **kwargs)
1137
1138 self._axstack.add(key, a)

/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py in init(self, fig, rect, facecolor, frameon, sharex, sharey, label, xscale, yscale, **kwargs)
537
538 if len(kwargs):
--> 539 self.update(kwargs)
540
541 if self.xaxis is not None:

/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py in update(self, props)
886 try:
887 ret = [_update_property(self, k, v)
--> 888 for k, v in props.items()]
889 finally:
890 self.eventson = store

/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py in (.0)
886 try:
887 ret = [_update_property(self, k, v)
--> 888 for k, v in props.items()]
889 finally:
890 self.eventson = store

/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py in update_property(self, k, v)
879 func = getattr(self, 'set
' + k, None)
880 if not callable(func):
--> 881 raise AttributeError('Unknown property %s' % k)
882 return func(v)
883

AttributeError: Unknown property axisbg

UserWarning: Bad circle positioning warnings.warn("Bad circle positioning") AND AttributeError: 'NoneType' object has no attribute 'get_path'

Hello @paulbrodersen ,
`[files.zip](https://github.com/paulbrodersen/matplotlib_venn_wordcloud/files/4578804/files.zip)`

Thanks a lot for this amazing work. 

As mentioned above, i'm getting these two error, the first is the UserWarming ***UserWarning: Bad circle positioning
  warnings.warn("Bad circle positioning")*** AND the second is the  ***AttributeError: 'NoneType' object has no attribute 'get_path'***. I'm using two Dataframes, from witch i build three sets of words lists. 

I have this error when i try to increase the size of the dataframe (number of  line). In this example, df[:20] and df1[:20] work good, but  df[:100] and df1[:100] do not and raise this error.

Here is my code :
`
###here  your venn3 function
def ex2(f,f1,f2):
    venn3_wordcloud([set(f), set(f1), set(f2)],
                    set_labels=['c_value','umls','tf-idf-c_m'],alpha = 0.3)
    return

### here's my sets builder
def setbuider(f,f1):
    df = pd.read_csv(f, sep="\t|,", engine='python')
    df = df[:20] #20 works but not 100
    cv = df['terms']
    umls1 = df[df['in_umls'] == 1]
    umls1 = umls1['terms']
    ###
    df1 = pd.read_csv(f1, sep="\t|,", engine='python')
    df1 = df1[:20] #20 works but not 100
    tf = df1['terms']
    ###
    umls2 = df1[df1['in_umls'] == 1]
    umls2 = umls2['terms']
    umls = pd.concat([umls1, umls2])
    ex2(cv,umls,tf) # i call venn3 with the three sets
##calling setbuider function
setbuider(f,f1)`

In attached, a zip that contains the two dataframes.

Many thanks again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.