Skip to content

Commit

Permalink
Add colormap option for plot_grid_var.py and grid_var frame generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Tootle committed Jul 1, 2022
1 parent 0a3dcb5 commit 8f21f26
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

#### General
- Add option to change default colormap for `plot_grid_var.py` and `grid_var` examples

## Version 1.3.5 (14 June 2022)

#### Bug fixes
Expand Down
14 changes: 12 additions & 2 deletions examples/bins/plot_grid_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
# well.

if __name__ == "__main__":
setup_matplotlib()

desc = f"""\
{kah.get_program_name()} plot a given grid function.
Expand Down Expand Up @@ -109,8 +107,20 @@
action="store_true",
help="Whether to take the absolute value.",
)
parser.add_argument(
"--cmap",
help="Set matplotlib built-in cmap. default: inferno",
default=None,
type=str,
)
args = kah.get_args(parser)

params = None
if args.cmap is not None:
params = {"image.cmap": args.cmap}

setup_matplotlib(params=params)

# Parse arguments

iteration = args.iteration
Expand Down
12 changes: 11 additions & 1 deletion examples/mopi_movies/grid_var
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def mopi_add_custom_options(parser):
action="store_true",
help="Whether to take the absolute value.",
)
parser.add_argument(
"--cmap",
help="Set matplotlib built-in cmap. default: inferno",
default=None,
type=str,
)


class MOPIMovie:
Expand Down Expand Up @@ -130,7 +136,11 @@ class MOPIMovie:
# Here we plot a frame. This function has to take the output path and
# the identifier of what is a frame (in this case, an iteration).

setup_matplotlib()
params = None
if self.args.cmap is not None:
params = {"image.cmap": self.args.cmap}

setup_matplotlib(params=params)
clear_figure()

if self.args.absolute:
Expand Down

0 comments on commit 8f21f26

Please sign in to comment.