Wordcloud background image multi-graphics presentation


foreword

Hello everyone, I am Kongkong star. In this article, I will share with you the multi-graphics demonstration of the wordcloud background image.


1. Problems

If the background of a picture is processed, will the word cloud be affected. If this picture has multiple layers, is it overlapping (or if there are multiple separate graphics, a word cloud will appear on one graphic, and the other will also appear.)

2. Multi-layer

1. Partial overlap

1.1 Background image

1.2 Word Cloud Map

2. Full overlap

2.1 Background image

2.2 Word Cloud Map

3. No overlapping

3.1 Background image

3.2 Word Cloud Map

3. Different shapes

1. Background image

2. Word Cloud Map

4. Code

import jieba
import numpy as np
from PIL import Image
from wordcloud import WordCloud
local = '/Users/kkstar/Downloads/video/pic/'
text = "Hello everyone, I am Kongkong star, I love posting news, I like to use search engine mode for word segmentation "
cut_text = " ".join(jieba.cut_for_search(text))
mask = np.array(Image.open(local+“heart.png”))
wc = WordCloud(font_path="STHeitiMedium.ttc", # set font
background_color= 'white', # Set the background color
mask=mask, # Set the background image
max_words=2000, # Set the maximum number of displayed words
max_font_size=100, # Set the maximum font
width=500, # Set the width of the canvas
height=500, # set the height of the canvas
)
wc.generate(cut_text)
wc.to_file(local+"wordcloud.png")


Summarize

  • If the background of an image is processed, will the word cloud be affected:

Yes, if the background of the image is manipulated, the word cloud may be affected. The specific impact depends on the way the background is processed and the algorithm used for word cloud generation. If background processing causes changes in color, brightness, contrast, etc., it may affect the readability and presentation of words in the word cloud. In addition, if the background processing involves the content of the image, such as removing some elements related to the word cloud or adding some elements not related to the word cloud, it will also affect the presentation of the word cloud. Therefore, before generating a word cloud, it is best to properly process the image to ensure that the presentation of the word cloud is as expected.

  • If this picture has multiple layers, is it overlapping:

Yes, if the wordcloud background image has multiple layers, then they will overlap.

  • If there are multiple separate graphs, a word cloud will appear on one graph, and another one will also appear:

Yes, multiple individual graphs can generate multiple word clouds, each word cloud generated from the content of its corresponding graph. These word clouds can be displayed in different positions, or can be combined into one large word cloud to show the keywords of the entire dataset. The specific display method depends on the effect you want to present and the characteristics of the data set.

Guess you like

Origin blog.csdn.net/weixin_38093452/article/details/130731444