# PySide6-WordCloud-Tool **Repository Path**: flyingpan/PySide6-WordCloud-Tool ## Basic Information - **Project Name**: PySide6-WordCloud-Tool - **Description**: 使用Python中的PySide6和WordCloud制作的⭐词云图生成小工具⭐,☄️软件可以直接下载使用~ 代码写的不好,请大佬们多多指教~谢谢啦~🌸🌸🌸 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2024-03-10 - **Last Updated**: 2025-04-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 词云图生成工具 image-20220928093513686 > **传送站:** > > 博客:https://blog.csdn.net/Pan_peter > > 视频:https://space.bilibili.com/279540198 ## 运行 > 下载python版本>=3.9 > > pip install -r requirements.txt > > python main.py ## 工具使用方法 > 选择【词语页面】——导入Excel文件 > > 选择【形状页面】——导入png图片 > > 选择【字体页面】——导入字体 > > 选择【配置】——可以自定义相关数据 > 点击【生成词云图】——将可以在页面左边看见图片效果 > > 点击【保存词云图】——将会把当前生成的图片保存下来 ## 注意事项 > 导入相关文件——文件路径不能存在中文! > > 对于一些非法操作会导致执行失败(会有相关提示) > ## 功能未完成 > 图片保存功能(保存为标清,高清) > > 文字排版功能(选择角度) > > 文字步长设置功能 > > 超多参数设置——未完成 ## 项目来源 > 当时做word需要美化一个词云图,结果搞了半天,都要收钱,当时还好有一个国外的网站,是免费的 > > 所以,当时就想自己做一个,我之前就知道python有一个库可以实现 > > 然后正好这个周实习,实习的时候,没有很忙,大多数时间都在划水,就写了这一个小工具 > > 但是后面发现参数实在太多,做乏了,就没有设置完成,唉,就这样了吧,我只设置了一些我需要的参数 > > 还有一点,就是这个图片可以设置轮廓的,但是要有轮廓的话,就不能是透明的,那么就无法垫图了 > > 这个背景颜色是用OpenCV实现的图像融合到一起就可以了 ## 参数 & 方法 | fit_words(frequencies) | 无 | 根据词频分布调整词的大小和位置 | | ------------------------------------------- | ---------------------------------- | ------------------------------ | | generate(text) | 无 | 生成词云图像 | | generate_from_frequencies(frequencies) | 无 | 根据给定词频分布生成词云图像 | | generate_from_text(text) | 无 | 根据给定文本生成词云图像 | | process_text(text) | 无 | 处理文本,用于生成词云 | | recolor(random_state, color_func, colormap) | random_state, color_func, colormap | 重新着色词云图像 | | to_array() | 无 | 将词云图像转换为数组 | | to_file(filename) | filename | 将词云图像保存到指定文件 | | 参数名 | 类型 | 默认值 | 描述 | | ----------------- | ---------------------- | --------- | -------------------- | | font_path | string | 无 | 字体路径 | | width | int | 400 | 画布宽度 | | height | int | 200 | 画布高度 | | prefer_horizontal | float | 0.90 | 水平排版频率 | | mask | nd-array or None | None | 遮罩 | | scale | float | 1 | 画布放大比例 | | min_font_size | int | 4 | 最小字体大小 | | font_step | int | 1 | 字体步长 | | max_words | number | 200 | 最大词数 | | stopwords | set of strings or None | None | 屏蔽词 | | background_color | color value | "black" | 背景颜色 | | max_font_size | int or None | None | 最大字体大小 | | mode | string | "RGB" | 模式 | | relative_scaling | float | 0.5 | 词频和字体大小关联性 | | color_func | callable | None | 颜色函数 | | regexp | string or None | None | 正则表达式 | | collocations | bool | True | 是否包括搭配 | | colormap | string or colormap | "viridis" | 颜色映射 | | Parameter | Default Value | Description | | ----------------- | ------------- | ------------------------------------------------ | | font_path | None | Path to the font file | | width | 400 | Width of the word cloud image | | height | 200 | Height of the word cloud image | | margin | 2 | Margin around the words | | ranks_0nly | None | Include only words with a certain ranking | | prefer_horizontal | 0.9 | Probability of a word being horizontal | | mask | None | Image mask for the word cloud | | scale | 1 | Scaling factor for the font sizes | | color_func | None | Function to generate colors for words | | max_words | 200 | Maximum number of words to include | | min_font_size | 4 | Minimum font size | | stopwords | None | List of stopwords to exclude | | random_state | None | Seed for random number generation | | background_color | 'black' | Background color of the word cloud | | max_font_size | None | Maximum font size | | font_step | 1 | Font size step | | mode | 'RGB' | Image mode | | relative_scaling | 'auto' | Scaling of font sizes relative to frequencies | | regexp | None | Regular expression for selecting words | | collocations | True | Include collocations (phrases) in the word cloud | | colormap | None | Colormap for coloring words | | normalize_plurals | True | Normalize plurals (e.g., 'apple' and 'apples') | | contour_width | θ | Width of the word contour | | contour_color | 'blackI' | Color of the word contour | | repeat | False | Allow repeated words | | font_path | None | 字体文件路径。 | | ----------------- | --------- | -------------------------------------- | | width | 400 | 生成词云图的宽度。 | | height | 200 | 生成词云图的高度。 | | margin | 2 | 词云图的边缘宽度。 | | ranks_only | None | 是否仅使用排名进行排列。 | | prefer_horizontal | 0.9 | 水平方向上词云图中单词的倾向性。 | | mask | None | 词云形状的遮罩图像。 | | scale | 1 | 词云图的缩放比例。 | | color_func | None | 用于生成词云图颜色的函数。 | | max_words | 200 | 词云图中显示的最大单词数量。 | | min_font_size | 4 | 词云图中显示的最小字体大小。 | | stopwords | None | 需要排除的停用词列表。 | | random_state | None | 用于生成词云图的伪随机数生成器的种子。 | | background_color | 'black' | 词云图的背景颜色。 | | max_font_size | None | 词云图中显示的最大字体大小。 | | font_step | 1 | 字体大小的步长。 | | mode | 'RGB' | 生成图像的模式。 | | relative_scaling | 'auto' | 单词频率和字体大小之间的相对缩放比例。 | | regexp | None | 用于分割输入文本的正则表达式。 | | collocations | True | 是否考虑词组搭配(collocations)。 | | colormap | None | 词云图的颜色映射。 | | normalize_plurals | True | 是否对单词进行复数形式的标准化。 | | contour_width | θ (theta) | 词云图中轮廓的宽度。 | | contour_color | 'black' | 词云图中轮廓的颜色。 | | repeat | False | 是否允许单词在词云图中重复出现。 | ## 参考文章 > 色卡: > > https://blog.csdn.net/geekqian/article/details/122599683 > https://matplotlib.org/examples/color/colormaps_reference.html > > word_cloud官方: > > https://github.com/amueller/word_cloud