supposed wordcloud fix, but everything broke
This commit is contained in:
20
plots.py
20
plots.py
@@ -1305,6 +1305,16 @@ class QualtricsPlotsMixin:
|
||||
# Create frequency dictionary
|
||||
trait_freq = Counter(traits_list)
|
||||
|
||||
# Handle empty data gracefully - return empty figure with message
|
||||
if not trait_freq:
|
||||
fig, ax = plt.subplots(figsize=(width/100, height/100), dpi=100)
|
||||
ax.text(0.5, 0.5, "No trait data available for current filter",
|
||||
ha='center', va='center', fontsize=14, color='gray',
|
||||
transform=ax.transAxes)
|
||||
ax.axis('off')
|
||||
ax.set_title(title, fontsize=16, pad=20, color=ColorPalette.TEXT)
|
||||
return fig
|
||||
|
||||
# Set random seed for color selection
|
||||
random.seed(random_state)
|
||||
|
||||
@@ -1335,7 +1345,15 @@ class QualtricsPlotsMixin:
|
||||
fig, ax = plt.subplots(figsize=(width/100, height/100), dpi=100)
|
||||
ax.imshow(wordcloud, interpolation='bilinear')
|
||||
ax.axis('off')
|
||||
ax.set_title(title, fontsize=16, pad=20, color=ColorPalette.TEXT)
|
||||
|
||||
# Add title with filter subtitle (similar to _add_filter_footnote for Altair charts)
|
||||
filter_text = self._get_filter_description()
|
||||
if filter_text:
|
||||
# Title on top, filter subtitle below in light grey
|
||||
fig.suptitle(title, fontsize=16, y=0.98, color=ColorPalette.TEXT)
|
||||
ax.set_title(filter_text, fontsize=10, pad=10, color='lightgrey', loc='left')
|
||||
else:
|
||||
ax.set_title(title, fontsize=16, pad=20, color=ColorPalette.TEXT)
|
||||
|
||||
plt.tight_layout(pad=0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user