Skip to content

Commit

Permalink
wordcloud styling
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Dec 5, 2024
1 parent 6f4c61b commit dcbc269
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stackview/_wordcloudplot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def wordcloudplot(df, column_x: str = "x", column_y: str = "y", column_text: str = "text",
column_selection: str = "selection",
figsize=(4, 4), markersize=4):
figsize=(4, 4), markersize=4, width=400, height=400):
"""
Visualizes a scatter plot of columns in a given dataframe next to a word cloud.
Per default, the dataframe should contain a column "text".
Expand All @@ -21,6 +21,10 @@ def wordcloudplot(df, column_x: str = "x", column_y: str = "y", column_text: str
The size of the scatter plot figure
markersize: int
The size of the markers
width: int
The width of the word cloud
height: int
The height of the word cloud
Returns
-------
Expand All @@ -41,7 +45,7 @@ def wordcloudplot(df, column_x: str = "x", column_y: str = "y", column_text: str
selected_texts = df[column_text]
text = "\n".join(selected_texts)

wordcloud = WordCloud().generate(text)
wordcloud = WordCloud(colormap="twilight", background_color="white", width=width, height=height).generate(text)
image = wordcloud.to_image()
selected_image = np.array(image)

Expand All @@ -54,7 +58,7 @@ def update(selection, df, column_text, selected_image, widget):
if len(text) == 0:
text = "empty wordcloud"

wordcloud = WordCloud().generate(text)
wordcloud = WordCloud(colormap="twilight", background_color="white", width=width, height=height).generate(text)
image = wordcloud.to_image()
temp = np.array(image)

Expand Down

0 comments on commit dcbc269

Please sign in to comment.