From 88e6b532a96ca5df828b35db74bfe5fb9c44ebff Mon Sep 17 00:00:00 2001 From: Miguel de la Varga Date: Wed, 29 Oct 2025 13:57:53 +0100 Subject: [PATCH 1/3] [ENH] Add customization options for surface points and orientations drawing Introduce `kwargs_surface_points` and `kwargs_orientations` to allow overriding default settings in 2D plot rendering. Updated `_plot_2d_sections_api` and `drawer_input_2d` to support these additional parameters, enabling more flexible visualization customization --- gempy_viewer/API/_plot_2d_sections_api.py | 8 ++- .../modules/plot_2d/drawer_input_2d.py | 53 +++++++++++++------ 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/gempy_viewer/API/_plot_2d_sections_api.py b/gempy_viewer/API/_plot_2d_sections_api.py index 52dd9cd..9722c31 100644 --- a/gempy_viewer/API/_plot_2d_sections_api.py +++ b/gempy_viewer/API/_plot_2d_sections_api.py @@ -24,10 +24,14 @@ def plot_sections(gempy_model: GeoModel, sections_data: list[SectionData2D], dat kwargs_scalar_field: dict = None, kwargs_lithology: dict = None, kwargs_boundaries: dict = None, + kwargs_surface_points: dict = None, + kwargs_orientations: dict = None, ): kwargs_lithology = kwargs_lithology if kwargs_lithology is not None else {} kwargs_scalar_field = kwargs_scalar_field if kwargs_scalar_field is not None else {} kwargs_topography = kwargs_topography if kwargs_topography is not None else {} + kwargs_surface_points = kwargs_surface_points if kwargs_surface_points is not None else {} + kwargs_orientations = kwargs_orientations if kwargs_orientations is not None else {} series_n = series_n if series_n is not None else [0] @@ -43,7 +47,9 @@ def plot_sections(gempy_model: GeoModel, sections_data: list[SectionData2D], dat orientations_colors=gempy_model.structural_frame.orientations_colors_per_item, orientations=gempy_model.orientations_copy.df.copy(), points=gempy_model.surface_points_copy.df.copy(), - slicer_data=section_data.slicer_data + slicer_data=section_data.slicer_data, + kwargs_surface_points=kwargs_surface_points, + kwargs_orientations=kwargs_orientations, ) if data_to_show.show_lith[e] is True: diff --git a/gempy_viewer/modules/plot_2d/drawer_input_2d.py b/gempy_viewer/modules/plot_2d/drawer_input_2d.py index 89ba523..53b9643 100644 --- a/gempy_viewer/modules/plot_2d/drawer_input_2d.py +++ b/gempy_viewer/modules/plot_2d/drawer_input_2d.py @@ -15,41 +15,60 @@ # TODO: This could be public and the slice just a class yes! def draw_data(ax, surface_points_colors: list[str], orientations_colors: list[str], - orientations: 'pd.DataFrame', points: 'pd.DataFrame', slicer_data: SlicerData): + orientations: 'pd.DataFrame', points: 'pd.DataFrame', slicer_data: SlicerData, + kwargs_surface_points: dict = None, + kwargs_orientations: dict = None): - _draw_surface_points(ax, points, slicer_data, surface_points_colors) - _draw_orientations(ax, orientations, orientations_colors, slicer_data) + kwargs_surface_points = kwargs_surface_points if kwargs_surface_points is not None else {} + kwargs_orientations = kwargs_orientations if kwargs_orientations is not None else {} + + _draw_surface_points(ax, points, slicer_data, surface_points_colors, **kwargs_surface_points) + _draw_orientations(ax, orientations, orientations_colors, slicer_data, **kwargs_orientations) -def _draw_orientations(ax, orientations, orientations_colors, slicer_data): +def _draw_orientations(ax, orientations, orientations_colors, slicer_data, **kwargs): sel_ori = orientations[slicer_data.select_projected_o] aspect = np.subtract(*ax.get_ylim()) / np.subtract(*ax.get_xlim()) min_axis = 'width' if aspect < 1 else 'height' + + # Default values that can be overridden by kwargs + default_kwargs = { + 'pivot': 'tail', + 'scale_units': min_axis, + 'scale': 30, + 'color': np.array(orientations_colors)[slicer_data.select_projected_o], + 'edgecolor': 'k', + 'headwidth': 8, + 'linewidths': 1, + 'zorder': 102 + } + default_kwargs.update(kwargs) + ax.quiver( sel_ori[slicer_data.x], sel_ori[slicer_data.y], sel_ori[slicer_data.Gx], sel_ori[slicer_data.Gy], - pivot="tail", - scale_units=min_axis, - scale=30, - color=np.array(orientations_colors)[slicer_data.select_projected_o], - edgecolor='k', - headwidth=8, - linewidths=1, - zorder=102 + **default_kwargs ) -def _draw_surface_points(ax, points, slicer_data, surface_points_colors): +def _draw_surface_points(ax, points, slicer_data, surface_points_colors, **kwargs): points_df = points[slicer_data.select_projected_p] + + # Default values that can be overridden by kwargs + default_kwargs = { + 'c': np.array(surface_points_colors)[slicer_data.select_projected_p], + 's': 70, + 'edgecolors': 'white', + 'zorder': 102 + } + default_kwargs.update(kwargs) + ax.scatter( points_df[slicer_data.x], points_df[slicer_data.y], - c=(np.array(surface_points_colors)[slicer_data.select_projected_p]), - s=70, - edgecolors='white', - zorder=102 + **default_kwargs ) From 12222038b06c7042f0daf10dfaa828dbc6fdc20d Mon Sep 17 00:00:00 2001 From: Miguel de la Varga Date: Thu, 6 Nov 2025 08:58:17 +0100 Subject: [PATCH 2/3] [ENH] Add `contour_colors` option for customizable 2D contour plotting Allow overriding default contour colors in 2D plots by introducing the `contour_colors` parameter in `drawer_contours_2d`. This enables more flexible color customization for improved visualization. --- gempy_viewer/modules/plot_2d/drawer_contours_2d.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gempy_viewer/modules/plot_2d/drawer_contours_2d.py b/gempy_viewer/modules/plot_2d/drawer_contours_2d.py index ad687c9..d3e5d9c 100644 --- a/gempy_viewer/modules/plot_2d/drawer_contours_2d.py +++ b/gempy_viewer/modules/plot_2d/drawer_contours_2d.py @@ -16,10 +16,11 @@ def plot_regular_grid_contacts(gempy_model: GeoModel, ax: matplotlib.axes.Axes, kwargs = {} zorder = kwargs.get('zorder', 100) + contour_colors = kwargs.get('contour_colors', None) shape = resolution c_id = 0 # * color id startpoint - all_colors = gempy_model.structural_frame.elements_colors_contacts + all_colors = contour_colors if contour_colors is not None else gempy_model.structural_frame.elements_colors_contacts for e, block in enumerate(gempy_model.solutions.raw_arrays.scalar_field_matrix): _scalar_field_per_surface = np.where(gempy_model.solutions.raw_arrays.scalar_field_at_surface_points[e] != 0) From c084e1839d9f223ed4dc6b8b1fc13dabaaff206e Mon Sep 17 00:00:00 2001 From: Miguel de la Varga Date: Tue, 18 Nov 2025 14:19:18 +0100 Subject: [PATCH 3/3] [MAINT] Remove `gempy_engine` dependency from requirements files Cleaned up `gempy_engine` references in `dev-requirements.txt` and `requirements.txt` to streamline dependencies. --- requirements/dev-requirements.txt | 1 - requirements/requirements.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index 16d7e8e..156449c 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -5,5 +5,4 @@ gempy imagehash pillow pydantic -gempy_engine>=2025.2.0dev0,<2025.3.0 gempy>=2025.2.0dev0,<2025.3.0 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index dd24173..db5d81e 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,3 +1,2 @@ matplotlib numpy -gempy_engine>=2025.3dev0 \ No newline at end of file