Created
December 10, 2019 15:13
-
-
Save szapp/fe6216e20298988815fadf7db7f50b0b to your computer and use it in GitHub Desktop.
Quick plotting functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Quick plotting for testing and preliminary data visualization | |
""" | |
from matplotlib import pyplot as plt | |
from matplotlib.colors import LinearSegmentedColormap | |
import numpy as np | |
__all__ = [ | |
'imshow', | |
] | |
# Default color map | |
dflt_cmap = LinearSegmentedColormap.from_list('rwb', ['red', 'white', 'black']) | |
def imshow(a, **kwargs): | |
mm = np.abs(a).max() | |
args = { | |
'cmap': dflt_cmap, | |
'vmin': -mm, | |
'vmax': mm, | |
'origin': 'lower', | |
} | |
args.update(kwargs) | |
plt.imshow(a, **args) | |
plt.colorbar() | |
plt.gca().xaxis.get_major_locator().set_params(integer=True) | |
plt.gca().yaxis.get_major_locator().set_params(integer=True) | |
plt.gca().set_xticks(range(int(plt.gca().get_xlim()[0]), | |
int(plt.gca().get_xlim()[1]) + 1), minor=True) | |
plt.gca().set_yticks(range(int(plt.gca().get_ylim()[0]), | |
int(plt.gca().get_ylim()[1]) + 1), minor=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: