fixed plot alt-text-tag function
This commit is contained in:
8
plots.py
8
plots.py
@@ -952,6 +952,7 @@ class JPMCPlotsMixin:
|
||||
width: int = 1600,
|
||||
height: int = 800,
|
||||
background_color: str = 'white',
|
||||
random_state: int = 23,
|
||||
):
|
||||
"""Create a word cloud visualization of personality traits from survey data.
|
||||
|
||||
@@ -962,6 +963,7 @@ class JPMCPlotsMixin:
|
||||
width: Width of the word cloud image in pixels
|
||||
height: Height of the word cloud image in pixels
|
||||
background_color: Background color for the word cloud
|
||||
random_state: Random seed for reproducible word cloud generation (default: 23)
|
||||
|
||||
Returns:
|
||||
matplotlib.figure.Figure: The word cloud figure for display in notebooks
|
||||
@@ -983,6 +985,9 @@ class JPMCPlotsMixin:
|
||||
# Create frequency dictionary
|
||||
trait_freq = Counter(traits_list)
|
||||
|
||||
# Set random seed for color selection
|
||||
random.seed(random_state)
|
||||
|
||||
# Color function using JPMC colors
|
||||
def color_func(word, font_size, position, orientation, random_state=None, **kwargs):
|
||||
colors = [
|
||||
@@ -1002,7 +1007,8 @@ class JPMCPlotsMixin:
|
||||
relative_scaling=0.5,
|
||||
min_font_size=10,
|
||||
prefer_horizontal=0.7,
|
||||
collocations=False # Treat each word independently
|
||||
collocations=False, # Treat each word independently
|
||||
random_state=random_state # Seed for reproducible layout
|
||||
).generate_from_frequencies(trait_freq)
|
||||
|
||||
# Create matplotlib figure
|
||||
|
||||
Reference in New Issue
Block a user