It is very easy to create a transparent background word cloud image using python wordcloud library. In this tutorial, we will introduce you how to do.
Preliminary
Install and import python wordcloud.
from wordcloud import WordCloud
Then we can create a transparent background word cloud image.
Create a transparent background word cloud image
Here is the example code:
wc = WordCloud(mode = "RGBA", background_color=None, width = 300, height=300, margin=2) text = ''' It is very easy to create a transparent background word cloud image using python wordcloud library. In this tutorial, we will introduce you how to do. ''' wc.generate(text) wc.to_file('wc1.png')
Here we use mode = “RGBA”, background_color=None to create a WordCloud instance, this instance will create a transparent background word cloud image.
Run this code, you will get this image: