|
9 | 9 | import numpy as np |
10 | 10 | import numpy.typing as npt |
11 | 11 | import polars as pl |
| 12 | +from matplotlib import __version__ as mpl_version |
12 | 13 | from matplotlib.backend_bases import MouseEvent, PickEvent |
13 | 14 | from matplotlib.backends.backend_qt5agg import FigureCanvas # type: ignore |
14 | 15 | from matplotlib.collections import PathCollection |
15 | 16 | from matplotlib.figure import Figure |
16 | | -from mpl_toolkits.mplot3d import Axes3D |
| 17 | +from mpl_toolkits.mplot3d import Axes3D, axis3d |
17 | 18 | from mpl_toolkits.mplot3d.art3d import Line3DCollection |
18 | 19 | from polars.exceptions import ColumnNotFoundError |
19 | 20 | from PyQt6.QtCore import Qt |
|
41 | 42 | if TYPE_CHECKING: |
42 | 43 | from ert.config import ErtConfig |
43 | 44 |
|
| 45 | + |
| 46 | +def _install_mpl_3d_axis_regression_workaround() -> None: |
| 47 | + """Workaround for a matplotlib 3.11.0 regression when inverting 3D axes. |
| 48 | +
|
| 49 | + See issue: https://github.com/matplotlib/matplotlib/issues/31989 |
| 50 | + Fix expected in matplotlib 3.11.1 |
| 51 | + """ |
| 52 | + |
| 53 | + if mpl_version != "3.11.0": |
| 54 | + return |
| 55 | + |
| 56 | + original_get_coord_info = axis3d.Axis._get_coord_info |
| 57 | + |
| 58 | + def _get_coord_info( |
| 59 | + self: axis3d.Axis, |
| 60 | + ) -> tuple[ |
| 61 | + npt.NDArray[np.float64], |
| 62 | + npt.NDArray[np.float64], |
| 63 | + npt.NDArray[np.float64], |
| 64 | + npt.NDArray[np.bool_], |
| 65 | + ]: |
| 66 | + mins, maxs, bounds_proj, highs = original_get_coord_info(self) |
| 67 | + return np.minimum(mins, maxs), np.maximum(mins, maxs), bounds_proj, highs |
| 68 | + |
| 69 | + axis3d.Axis._get_coord_info = _get_coord_info |
| 70 | + |
| 71 | + |
| 72 | +_install_mpl_3d_axis_regression_workaround() |
| 73 | + |
| 74 | + |
44 | 75 | _FILTER_WIDTH = 200 |
45 | 76 | _DETAILS_WIDTH = 300 |
46 | 77 |
|
|
0 commit comments