fix missing filter descr in correlation plots
This commit is contained in:
22
plots.py
22
plots.py
@@ -253,7 +253,7 @@ class QualtricsPlotsMixin:
|
|||||||
|
|
||||||
return chart.properties(title=title_config)
|
return chart.properties(title=title_config)
|
||||||
|
|
||||||
def _save_plot(self, chart: alt.Chart, title: str, filename: str | None = None) -> alt.Chart:
|
def _save_plot(self, chart: alt.Chart, title: str, filename: str | None = None, skip_footnote: bool = False) -> alt.Chart:
|
||||||
"""Save chart to PNG file if fig_save_dir is set.
|
"""Save chart to PNG file if fig_save_dir is set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -261,11 +261,14 @@ class QualtricsPlotsMixin:
|
|||||||
title: Chart title (used for filename if filename not provided)
|
title: Chart title (used for filename if filename not provided)
|
||||||
filename: Optional explicit filename (without extension). If provided,
|
filename: Optional explicit filename (without extension). If provided,
|
||||||
this is used instead of deriving from title.
|
this is used instead of deriving from title.
|
||||||
|
skip_footnote: If True, skip adding filter footnote (use when footnote
|
||||||
|
was already added to a sub-chart before vconcat).
|
||||||
|
|
||||||
Returns the (potentially modified) chart with filter footnote added.
|
Returns the (potentially modified) chart with filter footnote added.
|
||||||
"""
|
"""
|
||||||
# Add filter footnote - returns combined chart if filters active
|
# Add filter footnote - returns combined chart if filters active
|
||||||
chart = self._add_filter_footnote(chart)
|
if not skip_footnote:
|
||||||
|
chart = self._add_filter_footnote(chart)
|
||||||
|
|
||||||
if hasattr(self, 'fig_save_dir') and self.fig_save_dir:
|
if hasattr(self, 'fig_save_dir') and self.fig_save_dir:
|
||||||
path = Path(self.fig_save_dir)
|
path = Path(self.fig_save_dir)
|
||||||
@@ -1382,11 +1385,14 @@ class QualtricsPlotsMixin:
|
|||||||
height=height or 350
|
height=height or 350
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add filter footnote to main chart before combining with legend
|
||||||
|
main_chart = self._add_filter_footnote(main_chart)
|
||||||
|
|
||||||
# Add custom legend below the chart
|
# Add custom legend below the chart
|
||||||
legend = self._create_gender_correlation_legend()
|
legend = self._create_gender_correlation_legend()
|
||||||
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
||||||
|
|
||||||
chart = self._save_plot(chart, title, filename=filename)
|
chart = self._save_plot(chart, title, filename=filename, skip_footnote=True)
|
||||||
return chart
|
return chart
|
||||||
|
|
||||||
def plot_speaking_style_ranking_correlation_by_gender(
|
def plot_speaking_style_ranking_correlation_by_gender(
|
||||||
@@ -1480,11 +1486,14 @@ class QualtricsPlotsMixin:
|
|||||||
height=height or 350
|
height=height or 350
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add filter footnote to main chart before combining with legend
|
||||||
|
main_chart = self._add_filter_footnote(main_chart)
|
||||||
|
|
||||||
# Add custom legend below the chart
|
# Add custom legend below the chart
|
||||||
legend = self._create_gender_correlation_legend()
|
legend = self._create_gender_correlation_legend()
|
||||||
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
||||||
|
|
||||||
chart = self._save_plot(chart, title, filename=filename)
|
chart = self._save_plot(chart, title, filename=filename, skip_footnote=True)
|
||||||
return chart
|
return chart
|
||||||
|
|
||||||
def plot_speaking_style_color_correlation(
|
def plot_speaking_style_color_correlation(
|
||||||
@@ -1629,11 +1638,14 @@ class QualtricsPlotsMixin:
|
|||||||
height=height or 350
|
height=height or 350
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add filter footnote to main chart before combining with legend
|
||||||
|
main_chart = self._add_filter_footnote(main_chart)
|
||||||
|
|
||||||
# Add custom legend below the chart
|
# Add custom legend below the chart
|
||||||
legend = self._create_gender_correlation_legend()
|
legend = self._create_gender_correlation_legend()
|
||||||
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
chart = alt.vconcat(main_chart, legend, spacing=10).resolve_scale(color='independent')
|
||||||
|
|
||||||
chart = self._save_plot(chart, title, filename=filename)
|
chart = self._save_plot(chart, title, filename=filename, skip_footnote=True)
|
||||||
return chart
|
return chart
|
||||||
|
|
||||||
def plot_demographic_distribution(
|
def plot_demographic_distribution(
|
||||||
|
|||||||
Reference in New Issue
Block a user