diff --git a/src/robofish/io/app.py b/src/robofish/io/app.py index 5122d586177cf0c0874b42ccbf86b858d3caef0b..9c352111019ec9606694fcff65299ecd86d00ba5 100644 --- a/src/robofish/io/app.py +++ b/src/robofish/io/app.py @@ -241,6 +241,16 @@ def render(args: argparse.Namespace = None) -> None: 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 = { "linewidth": 2, "speedup": 1, diff --git a/src/robofish/io/file.py b/src/robofish/io/file.py index 4a7fc71825c4a83bdc69616279774f2bd1bc16e7..a1b82e001e2c179f1961d54404d3152619304fd1 100644 --- a/src/robofish/io/file.py +++ b/src/robofish/io/file.py @@ -1004,6 +1004,7 @@ class File(h5py.File): render_zones: bool = False, render_swarm_center: bool = False, highlight_switches: bool = False, + custom_colors: bool = None, dpi: int = 200, figsize: int = 10, ) -> None: @@ -1058,7 +1059,17 @@ class File(h5py.File): categories = [entity.attrs.get("category", None) for entity in self.entities] 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)] fish_colors = [ color