Skip to content

Commit 03012b5

Browse files
committed
Make boxplot options available for seismic misfit plot
1 parent 5abc224 commit 03012b5

1 file changed

Lines changed: 26 additions & 85 deletions

File tree

src/ert/gui/plotting/ert_plots/misfits.py

Lines changed: 26 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import numpy as np
66
import pandas as pd
77
import polars as pl
8-
from matplotlib.lines import Line2D
98

109
from ert.gui.plotting.shared_plots.generic_boxplot_with_scatter import (
1110
generate_legend_items,
@@ -320,96 +319,38 @@ def _plot_seismic_mean_misfits(
320319
axes.set_ylim(y_min, y_max)
321320
axes.axhline(0.0, color="black", linewidth=0.5, alpha=0.5)
322321

323-
config = plot_context.plotConfig()
324322
for position, ens_key in zip(positions, plotted_keys, strict=True):
325323
color = color_map[ens_key]
326324
values = ensemble_misfits[ens_key]
327-
axes.boxplot(
325+
generate_plots(
326+
plot_context,
327+
axes,
328328
[values],
329-
positions=[position],
330-
widths=box_width,
331-
whis=(LOWER_PERCENTILE_FOR_WHISKERS, UPPER_PERCENTILE_FOR_WHISKERS),
332-
patch_artist=True,
333-
showfliers=True,
334-
boxprops={
335-
"facecolor": color,
336-
"alpha": 0.8,
337-
"edgecolor": color,
338-
"linewidth": 0.7,
339-
},
340-
whiskerprops={
341-
"color": color,
342-
"alpha": 1,
343-
"linewidth": 1,
344-
"linestyle": "--",
345-
},
346-
capprops={
347-
"color": color,
348-
"alpha": 1,
349-
"linewidth": 2,
350-
"linestyle": "--",
351-
},
352-
medianprops={"color": "black", "linewidth": 1, "alpha": 1},
353-
flierprops={
354-
"marker": "o",
355-
"alpha": 1,
356-
"markeredgewidth": 0.3 + (0.4 * (1 - box_width)),
357-
"markeredgecolor": color,
358-
"markerfacecolor": "none",
359-
},
360-
)
361-
axes.plot(
362-
position,
363-
float(np.nanmean(values)),
364-
"D",
365-
markersize=4,
366-
color="black",
367-
zorder=3,
368-
)
369-
median_val = float(np.nanmedian(values))
370-
axes.annotate(
371-
f"{median_val:.3g}",
372-
xy=(position + box_width / 2, median_val),
373-
xytext=(4, 0),
374-
textcoords="offset points",
375-
va="center",
376-
ha="left",
377-
fontsize=10,
378-
color="black",
379-
zorder=4,
329+
[position],
330+
box_width,
331+
color,
332+
LOWER_PERCENTILE_FOR_WHISKERS,
333+
UPPER_PERCENTILE_FOR_WHISKERS,
334+
legend_label=ens_key[0],
380335
)
336+
if plot_context.box_plot:
337+
median_val = float(np.nanmedian(values))
338+
axes.annotate(
339+
f"{median_val:.3g}",
340+
xy=(position + box_width / 2, median_val),
341+
xytext=(4, 0),
342+
textcoords="offset points",
343+
va="center",
344+
ha="left",
345+
fontsize=10,
346+
color="black",
347+
zorder=4,
348+
)
381349

382-
config.add_legend_item(
383-
"Median", Line2D([0], [0], color="black", linewidth=0.9, alpha=1)
384-
)
385-
config.add_legend_item(
386-
f"Whiskers ({LOWER_PERCENTILE_FOR_WHISKERS}-"
387-
f"{UPPER_PERCENTILE_FOR_WHISKERS} %)",
388-
Line2D([0], [0], color="black", linewidth=2, linestyle="--", alpha=1),
389-
)
390-
config.add_legend_item(
391-
"Outliers",
392-
Line2D(
393-
[0],
394-
[0],
395-
marker="o",
396-
color="none",
397-
markeredgecolor="black",
398-
markerfacecolor="none",
399-
markersize=6,
400-
alpha=1,
401-
),
402-
)
403-
config.add_legend_item(
404-
"Mean",
405-
Line2D(
406-
[0],
407-
[0],
408-
marker="D",
409-
linestyle="None",
410-
color="black",
411-
markersize=4,
412-
),
350+
generate_legend_items(
351+
plot_context,
352+
LOWER_PERCENTILE_FOR_WHISKERS,
353+
UPPER_PERCENTILE_FOR_WHISKERS,
413354
)
414355

415356
axes.set_xlim(-0.5, len(plotted_keys) - 0.5)

0 commit comments

Comments
 (0)