minimaxir / stylecloud Goto Github PK
View Code? Open in Web Editor NEWPython package + CLI to generate stylistic wordclouds, including gradients and icon shapes!
License: MIT License
Python package + CLI to generate stylistic wordclouds, including gradients and icon shapes!
License: MIT License
It would make this package much easier to use with twint and BigQuery.
I like the color options of stylecloud, but I would like to be able to just have a rectangle, no mask at all. Even if I specify None for icon it ignores me and does a flag!?
Hi,
when I run stylecloud on my PC I have no problem, but then I deploy it on an ubuntu machine and make it run inside a docker container activated through flask.
When I do so, I get an error as it seem the way palettable is imported (line 91 of your function) generates an error. Could you help me solve that? Can I avoid importing palettable and just give it the colors (even if I use the colors the palette is generated)?
File "/usr/lib/python3.8/site-packages/stylecloud/stylecloud.py", line 237, in gen_stylecloud
palette_func = gen_palette(palette)
File "/usr/lib/python3.8/site-packages/stylecloud/stylecloud.py", line 91, in gen_palette
return self.__local()
File "/usr/lib/python3.8/site-packages/flask/globals.py", line 38, in _lookup_req_object
raise RuntimeError(_request_ctx_err_msg)
RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.
import(
ModuleNotFoundError: No module named 'palettable.'
Thanks a lot for this nice package! :)
Attempting to run your example code:
import stylecloud
stylecloud.gen_stylecloud(file_path='constitution.txt')
I get the following traceback error:
Traceback (most recent call last):
File "/Users/d/Documents/word-clouds/generate_clouds.py", line 1, in <module>
import stylecloud
File "/usr/local/lib/python3.9/site-packages/stylecloud/__init__.py", line 1, in <module>
from .stylecloud import gen_stylecloud
File "/usr/local/lib/python3.9/site-packages/stylecloud/stylecloud.py", line 6, in <module>
from matplotlib.colors import makeMappingArray, to_rgb
ImportError: cannot import name 'makeMappingArray' from 'matplotlib.colors' (/usr/local/lib/python3.9/site-packages/matplotlib/colors.py)
Any suggestions on how to remedy this would be greatly appreciated!
As stated in the title I was wondering if there was a way to have no icon at all, so the words just fill up the entirety of the specified image
Greetings, Dear Author
I would like to set the background color to transparent. I set them to None; Transparent; #00000000 respectively. But unfortunately, the result was always a black background, which frustrated me. Your help will be very useful to me.
Hi. Is it possible to allow words to be repeated until the mask is full? If my text is not long enough, it doesn't fill the entire image. Like in wordcloud we can set repeat = True to repeat words until image is full or smallest text size is reached. Thanks
Single colors might look nice as duotones between stylecloud and background. Manual palettes could work well for branding.
In this case, gradient support would have to be disabled unless there's an easy way to interpolate colors. (maybe in matplotlib
?)
While I try to read a file contain Chinese:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 22: character maps to
Could you change code in both lines 22 and 27 in stylecloud.py to
with open(file_path, 'r', encoding="utf8") as f:
Thanks!
Current implementation is O(n^2). There really should be a O(n) implementation with numpy (calculate gradient vector once, multiply by n) but the data formats for everything involved are fickle.
Hi,
Thanks for this useful tool! May I kindly ask if it is possible to have the function generate the image from a frequency dictionary just like what wordcloud did?
Best,
Jun
Encountered a problem when using Python 3.12, problem one is causing an exception:'ImageDraw' object has no attribute 'textsize'
,I attempted to downgrade PIL to version 9.5 and resolved the issue. However, when used in 'jupyter', it will continue to occupy the process and cannot calculate the result, and even when executed directly in '. py', the result cannot be obtained.I noticed a warning in the background while running in 'jupyter',It seems that frozen modules are being used, which may
.I'm not sure if it's related to this issue.
You project seems not to support Chinese. Will you add this function in the future?
https://blog.fontawesome.com/download-font-awesome-with-python-pip/
May or may not work since stylecloud does shennanigans with the font file.
Thanks for stylecloud, it produces awesome results!
One thought: rather than defaulting to a specific icon, could you scan through the common words above a certain minimum threshold, in order, and see if any match the name of an icon? (You could still have a fallback in case none match.) That seems likely to produce amusing, self-describing results; the word describing the icon used as a mask will also appear large in the image.
Trying to use stylecloud gives me this error: 'ImageDraw' object has no attribute 'textsize'
I found this on stack overflow, sounds like it's probably the cause:
"The ImageDraw.textsize() method was deprecated in PIL version 9.2.0 and completely removed beginning with version 10.0.0 on 2023-07-01. The ImageDraw.textbbox() method was introduced in version 8.0.0 as a more robust solution."
https://stackoverflow.com/questions/76189891/imagedraw-object-has-no-attribute-textbbox
Would it be possible to display inline in Jupyter notebook? right now gen_stylecloud
seems to be saving the png
stylecloud is a great library! It really simplifies the mask-array-based approach of word_cloud
when generate wordcloud constrained by a mask. But I want to get more control over the wordcloud it generate, e.g. I want to generate pure-horizontal wordcloud by set prefer_horizontal
to 1
, seems there's no way to pass this extra parameter into the constructor of WordCloud
.
BTW, is there any way to shrink space between words?
my code is:
from stylecloud import gen_stylecloud gen_stylecloud( text=' '.join(list3), size=512, font_path=r'C:\Windows\Fonts\msyh.ttc', output_name='C:/Users/.../Desktop/wordcloud.png', icon_name='fab fa-twitter', palette= cartocolors.qualitative.Bold_5 )
And this error occurred.
I Tried it Today inside Jupyter notebook but it is not working. Could you please check and fix it.
By default, it only will do the center.
Create a dedicated app (dependent on SVG support in wordcloud
)
I use stylecloud for japanese but it displays wrong font. How can I fix it? Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.