Skip to content

Commit b4c51a8

Browse files
committed
remove superfluous function, make docstring better
1 parent 5df8906 commit b4c51a8

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

src/sme_contrib/plot.py

-25
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
from matplotlib import pyplot as plt
55
from matplotlib.colors import LinearSegmentedColormap as lscmap
66
from matplotlib import animation
7-
from itertools import cycle
8-
import matplotlib.colors as mcolors
97
import pyvista as pv
108
from typing import Any, Callable
11-
import sme
129

1310
from .pyvista_utils import (
1411
find_layout,
@@ -37,28 +34,6 @@ def colormap(color, name="my colormap"):
3734
return lscmap.from_list(name, [(0, 0, 0), color], 256)
3835

3936

40-
def make_circular_colormap(
41-
cmap: str = "tab10", values: np.ndarray = np.array([])
42-
) -> list[tuple]:
43-
"""Create a discrete colormap of potentially repeating colors of the same size as the `values` array.
44-
45-
Args:
46-
cmap (str, optional): matplotlib colormap name. Defaults to "tab10".
47-
values (np.array, optional): values to be mapped to colors. Defaults to [].
48-
49-
Returns:
50-
list[tuple]: list of color in rgba format.
51-
"""
52-
cm = [(0.0, 0.0, 0.0, 1.0)]
53-
i = 0
54-
for c in cycle(plt.get_cmap(cmap).colors):
55-
cm.append(mcolors.to_rgba(c))
56-
if len(cm) >= len(values):
57-
break
58-
i += 1
59-
return cm
60-
61-
6237
def concentration_heatmap(
6338
simulation_result, species, z_slice: int = 0, title=None, ax=None, cmap=None
6439
):

src/sme_contrib/pyvista_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def rgb_to_scalar(img: np.ndarray) -> np.ndarray:
99
"""
10-
Convert an RGB 3D image represented as a 4D tensor to a 3D image tensor where each unique RGB value is assigned a unique scalar, i.e., it contracts the dimension with the RGB values into scalars. This is useful because PyVista doesn't work well with RGB values directly and expects fields defined on a grid, usually given by the tensor shape.
10+
Convert an RGB 3D image represented as a 4D tensor to a 3D image tensor where each unique RGB value is assigned a unique scalar, i.e., it contracts the dimension with the RGB values into scalars in such a way that 2 different colors are mapped to 2 different scalars, too. This is needed because PyVista doesn't work with RGB values directly and expects fields defined on a grid.
1111
1212
img (np.ndarray): A 3D numpy array representing an RGB image with shape (height, width, 3).
1313
@@ -25,7 +25,7 @@ def make_discrete_colormap(
2525
cmap: str = "tab10", values: np.ndarray = np.array([])
2626
) -> pv.LookupTable:
2727
"""
28-
Create a discrete colormap for use with PyVista.
28+
Create a discrete colormap for use with PyVista with as many colors as unique values in the `values`array based on a given matplotlbit colormap. The colors will possibly repeat if there are more unique values than colors in the colormap. In this case, the outcome is intended, e.g., for separability of regions in the visualization,
2929
3030
Parameters:
3131
cmap (str): The name of the colormap to use. Default is 'tab10'.

0 commit comments

Comments
 (0)