diff --git a/src/ydata_profiling/config.py b/src/ydata_profiling/config.py index e7e561e96..eb431f31d 100644 --- a/src/ydata_profiling/config.py +++ b/src/ydata_profiling/config.py @@ -173,6 +173,7 @@ class Plot(BaseModel): histogram: Histogram = Histogram() scatter_threshold: int = 1000 cat_freq: CatFrequencyPlot = CatFrequencyPlot() + font_path: Optional[Union[Path, str]] = None class Theme(Enum): diff --git a/src/ydata_profiling/config_default.yaml b/src/ydata_profiling/config_default.yaml index d2a0a472b..5d84d9663 100644 --- a/src/ydata_profiling/config_default.yaml +++ b/src/ydata_profiling/config_default.yaml @@ -159,6 +159,8 @@ plot: # Maximum number of bins (when bins=0) max_bins: 250 + font_path: null + # The number of observations to show n_obs_unique: 5 n_extreme_obs: 5 diff --git a/src/ydata_profiling/config_minimal.yaml b/src/ydata_profiling/config_minimal.yaml index 109043a28..d588ce037 100644 --- a/src/ydata_profiling/config_minimal.yaml +++ b/src/ydata_profiling/config_minimal.yaml @@ -159,6 +159,8 @@ plot: # Maximum number of bins (when bins=0) max_bins: 250 + font_path: null + # The number of observations to show n_obs_unique: 5 n_extreme_obs: 5 diff --git a/src/ydata_profiling/visualisation/plot.py b/src/ydata_profiling/visualisation/plot.py index 48d435152..f6942bb3c 100644 --- a/src/ydata_profiling/visualisation/plot.py +++ b/src/ydata_profiling/visualisation/plot.py @@ -27,6 +27,7 @@ def format_fn(tick_val: int, tick_pos: Any) -> str: def _plot_word_cloud( + config: Settings, series: Union[pd.Series, List[pd.Series]], figsize: tuple = (6, 4), ) -> plt.Figure: @@ -36,7 +37,12 @@ def _plot_word_cloud( for i, series_data in enumerate(series): word_dict = series_data.to_dict() wordcloud = WordCloud( - background_color="white", random_state=123, width=300, height=200, scale=2 + font_path=config.plot.font_path, + background_color="white", + random_state=123, + width=300, + height=200, + scale=2, ).generate_from_frequencies(word_dict) ax = plot.add_subplot(1, len(series), i + 1) @@ -124,7 +130,7 @@ def _plot_histogram( @manage_matplotlib_context() def plot_word_cloud(config: Settings, word_counts: pd.Series) -> str: - _plot_word_cloud(series=word_counts) + _plot_word_cloud(config=config, series=word_counts) return plot_360_n0sc0pe(config)