Allow arbitrary args to pcolormesh during visualization

lethe/LATEST
jan 7 years ago
parent c8cbf26a8c
commit a94a91446e

@ -1,4 +1,4 @@
from typing import List, Tuple, Callable from typing import List, Tuple, Callable, Dict
import numpy import numpy
from numpy import diff, floor, ceil, zeros, hstack, newaxis from numpy import diff, floor, ceil, zeros, hstack, newaxis
@ -762,7 +762,8 @@ class Grid(object):
center: float, center: float,
which_shifts: int = 0, which_shifts: int = 0,
sample_period: int = 1, sample_period: int = 1,
finalize: bool = True): finalize: bool = True,
pcolormesh_args: Dict = None):
""" """
Visualize a slice of a grid. Visualize a slice of a grid.
Interpolates if given a position between two planes. Interpolates if given a position between two planes.
@ -780,6 +781,9 @@ class Grid(object):
if isinstance(surface_normal, Direction): if isinstance(surface_normal, Direction):
surface_normal = surface_normal.value surface_normal = surface_normal.value
if pcolormesh_args is None:
pcolormesh_args = {}
grid_slice = self.get_slice(surface_normal=surface_normal, grid_slice = self.get_slice(surface_normal=surface_normal,
center=center, center=center,
which_shifts=which_shifts, which_shifts=which_shifts,
@ -792,7 +796,7 @@ class Grid(object):
x_label, y_label = ('xyz'[a] for a in surface) x_label, y_label = ('xyz'[a] for a in surface)
pyplot.figure() pyplot.figure()
pyplot.pcolormesh(xmesh, ymesh, grid_slice) pyplot.pcolormesh(xmesh, ymesh, grid_slice, **pcolormesh_args)
pyplot.colorbar() pyplot.colorbar()
pyplot.gca().set_aspect('equal', adjustable='box') pyplot.gca().set_aspect('equal', adjustable='box')
pyplot.xlabel(x_label) pyplot.xlabel(x_label)

Loading…
Cancel
Save