|
5 | 5 | import numpy as np |
6 | 6 | import pandas as pd |
7 | 7 | import polars as pl |
8 | | -from matplotlib.lines import Line2D |
9 | 8 |
|
10 | 9 | from ert.gui.plotting.shared_plots.generic_boxplot_with_scatter import ( |
11 | 10 | generate_legend_items, |
@@ -320,96 +319,38 @@ def _plot_seismic_mean_misfits( |
320 | 319 | axes.set_ylim(y_min, y_max) |
321 | 320 | axes.axhline(0.0, color="black", linewidth=0.5, alpha=0.5) |
322 | 321 |
|
323 | | - config = plot_context.plotConfig() |
324 | 322 | for position, ens_key in zip(positions, plotted_keys, strict=True): |
325 | 323 | color = color_map[ens_key] |
326 | 324 | values = ensemble_misfits[ens_key] |
327 | | - axes.boxplot( |
| 325 | + generate_plots( |
| 326 | + plot_context, |
| 327 | + axes, |
328 | 328 | [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], |
380 | 335 | ) |
| 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 | + ) |
381 | 349 |
|
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, |
413 | 354 | ) |
414 | 355 |
|
415 | 356 | axes.set_xlim(-0.5, len(plotted_keys) - 0.5) |
|
0 commit comments