in aggregate.py [0:0]
def _helper_plot_lines(data, save_dir):
sns_plots = []
data = get_transformer_data(transformer_data)(
data, get_col_kwargs(data, **dflt_kwargs)
)
for y, filename in gen_values_name(data):
if data[y].isna().all():
logger.info(f"Skipping {filename} because all nan.")
continue
_assert_sns_vary_only_cols(data, dflt_kwargs, cols_vary_only)
# replace `None` with "None" for string columns such that can see those
data = data.copy()
str_col = data.select_dtypes(include=object).columns
data[str_col] = data[str_col].fillna(value="None")
pretty_data = self.prettify(data)
pretty_kwargs = self.prettify_kwargs(
pretty_data, y=y, **dflt_kwargs)
sns_plot = sns.relplot(data=pretty_data, **pretty_kwargs)
if x_rotate != 0:
# calling directly `set_xticklabels` on FacetGrid removes the labels sometimes
for axes in sns_plot.axes.flat:
axes.set_xticklabels(
axes.get_xticklabels(), rotation=x_rotate)
if logbase_x != 1:
x_data = np.array(
sorted(pretty_data[pretty_kwargs["x"]].unique()))
plt.xscale(**kwargs_log_xscale(x_data, base=logbase_x))
if is_no_legend_title:
#! not going to work well if is_legend_out (double legend)
for ax in sns_plot.fig.axes:
handles, labels = ax.get_legend_handles_labels()
if len(handles) > 1:
ax.legend(handles=handles[1:], labels=labels[1:])
if xticks is not None:
sns_plot.set(xticks=xticks)
if xticklabels is not None:
sns_plot.set(xticklabels=xticklabels)
if xticks[0] > xticks[1]:
# dirty check to see if should reverse
for ax in sns_plot.axes.reshape(-1):
ax.invert_xaxis()
sns_plot.set(**set_kwargs)
if self.is_return_plots:
sns_plots.append(sns_plot)
else:
sns_plot.fig.savefig(
os.path.join(save_dir, f"{self.prfx}{filename}.png"),
dpi=self.dpi,
)
plt.close(sns_plot.fig)
if self.is_return_plots:
return sns_plots