Skip to content

Commit 3e7ec2a

Browse files
committed
[WIP] More testing for the colorbar
1 parent 5f21c7c commit 3e7ec2a

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

gempy_viewer/modules/plot_3d/drawer_input_3d.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def plot_data(gempy_vista: GemPyToVista,
2323
plot_surface_points(
2424
gempy_vista=gempy_vista,
2525
surface_points=surface_points_copy,
26-
elements_colors=model.structural_frame.elements_colors_contacts,
26+
elements_colors=model.structural_frame.elements_colors,
2727
**kwargs
2828
)
2929

@@ -61,15 +61,10 @@ def plot_surface_points(
6161
poly = pv.PolyData(xyz)
6262
poly['id'] = mapped_array
6363

64-
cmap = get_geo_model_cmap(
65-
elements_colors=np.array(elements_colors),
66-
reverse=False
67-
)
6864

6965
gempy_vista.surface_points_mesh = poly
7066
gempy_vista.surface_points_actor = gempy_vista.p.add_mesh(
7167
mesh=poly,
72-
cmap=cmap, # TODO: Add colors
7368
scalars='id',
7469
render_points_as_spheres=render_points_as_spheres,
7570
point_size=point_size,

gempy_viewer/modules/plot_3d/drawer_structured_grid_3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def add_regular_grid_mesh(
7171
mesh=structured_grid,
7272
cmap=cmap,
7373
# ? scalars=main_scalar, if we prepare the structured grid do we need this arg?
74-
show_scalar_bar=True,
74+
show_scalar_bar=False,
7575
scalar_bar_args=gempy_vista.scalar_bar_arguments,
7676
interpolate_before_map=True,
7777
opacity=opacity,

gempy_viewer/modules/plot_3d/plot_3d_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def set_scalar_bar(gempy_vista: GemPyToVista, elements_names: list[str],
4141

4242
# Create annotations mapping integers to element names
4343
annotations = {}
44-
for e, name in enumerate(elements_names[::-1]):
44+
for e, name in enumerate(elements_names):
4545
# Convert integer to string for the annotation key
4646
annotations[str(e)] = name
4747

@@ -50,15 +50,15 @@ def set_scalar_bar(gempy_vista: GemPyToVista, elements_names: list[str],
5050

5151
# Set number of colors to match the number of categories
5252
n_colors = len(elements_names)
53-
lut.n_values = n_colors
53+
lut.n_values = n_colors - 1
5454

5555
# Apply custom colors if provided
5656
if custom_colors is not None:
5757
# Check if we have enough colors
5858
if len(custom_colors) < n_colors:
5959
raise ValueError(f"Not enough custom colors provided. Got {len(custom_colors)}, need {n_colors}")
6060

61-
custom_cmap = ListedColormap(custom_colors)
61+
custom_cmap = ListedColormap(custom_colors).reversed()
6262

6363
# Apply the custom colormap to the lookup table
6464
lut.apply_cmap(cmap=custom_cmap, n_values=n_colors)
@@ -69,11 +69,12 @@ def set_scalar_bar(gempy_vista: GemPyToVista, elements_names: list[str],
6969

7070
# Configure scalar bar arguments
7171
sargs = gempy_vista.scalar_bar_arguments
72+
min_id, max_id = surfaces_ids.min(), surfaces_ids.max()
73+
mapper_actor.mapper.scalar_range = (min_id-.4 , max_id + .5)
7274
sargs["mapper"] = mapper_actor.mapper
75+
sargs["n_labels"] = 0
7376

7477
# Add scalar bar
7578
gempy_vista.p.add_scalar_bar(**sargs)
7679

7780
# Update scalar bar range to match surface IDs range
78-
min_id, max_id = surfaces_ids.min(), surfaces_ids.max()
79-
gempy_vista.p.update_scalar_bar_range((min_id, max_id))

tests/test_plotting/test_plot_3d.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from gempy_viewer.core.scalar_data_type import TopographyDataType
88
from tests.conftest import _one_fault_model_generator
99

10+
np.random.seed(1234)
1011

1112
class TestPlot3dInputData:
1213
def test_plot_3d_input_data(self, one_fault_model_no_interp):
@@ -15,11 +16,14 @@ def test_plot_3d_input_data(self, one_fault_model_no_interp):
1516

1617
class TestPlot3DSolutions:
1718
def test_plot_3d_solutions_default(self, one_fault_model_topo_solution):
19+
print(one_fault_model_topo_solution.structural_frame)
1820
gpv.plot_3d(one_fault_model_topo_solution, image=True)
1921

2022
def test_plot_3d_solutions(self, one_fault_model_topo_solution):
23+
print(one_fault_model_topo_solution.structural_frame)
2124
gpv.plot_3d(
2225
model=one_fault_model_topo_solution,
26+
show_topography=False,
2327
show_scalar=False,
2428
show_lith=True,
2529
show_data=True,

0 commit comments

Comments
 (0)