Skip to content
Snippets Groups Projects
Commit 14dc4f58 authored by mhocke's avatar mhocke
Browse files

Add cutom color support to rendering

parent 3c053452
No related branches found
No related tags found
1 merge request!50Merge dev_mathis with multiple changes
Pipeline #66463 failed
...@@ -241,6 +241,16 @@ def render(args: argparse.Namespace = None) -> None: ...@@ -241,6 +241,16 @@ def render(args: argparse.Namespace = None) -> None:
help="Last frame to render. Render until the end if set to 0.", help="Last frame to render. Render until the end if set to 0.",
) )
parser.add_argument(
"--custom-colors",
type=str,
nargs="+",
default=[],
help="Custom colors to use for guppies. Use spaces as delimiter. "
"To set all guppies to the same color, pass only one color. "
"Hexadecimal values, color names and matplotlib abbreviations are supported (\"#000000\", black, k)"
)
default_options = { default_options = {
"linewidth": 2, "linewidth": 2,
"speedup": 1, "speedup": 1,
......
...@@ -1004,6 +1004,7 @@ class File(h5py.File): ...@@ -1004,6 +1004,7 @@ class File(h5py.File):
render_zones: bool = False, render_zones: bool = False,
render_swarm_center: bool = False, render_swarm_center: bool = False,
highlight_switches: bool = False, highlight_switches: bool = False,
custom_colors: bool = None,
dpi: int = 200, dpi: int = 200,
figsize: int = 10, figsize: int = 10,
) -> None: ) -> None:
...@@ -1058,7 +1059,17 @@ class File(h5py.File): ...@@ -1058,7 +1059,17 @@ class File(h5py.File):
categories = [entity.attrs.get("category", None) for entity in self.entities] categories = [entity.attrs.get("category", None) for entity in self.entities]
n_fish = len([c for c in categories if c == "organism"]) n_fish = len([c for c in categories if c == "organism"])
lines = [plt.plot([], [], lw=linewidth, zorder=0)[0] for _ in range(n_entities)]
lines = [
plt.plot(
[],
[],
lw=linewidth,
color=custom_colors[i%len(custom_colors)-1] if custom_colors else None,
zorder=0,
)[0]
for i in range(n_entities)
]
entity_colors = [lines[entity].get_color() for entity in range(n_entities)] entity_colors = [lines[entity].get_color() for entity in range(n_entities)]
fish_colors = [ fish_colors = [
color color
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment