-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from BranniganLab/22-get_cmap-is-deprecated-in…
…-matplotlib 22 get cmap is deprecated in matplotlib
- Loading branch information
Showing
2 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Mon Nov 11 14:41:24 2024. | ||
@author: js2746 | ||
""" | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from matplotlib.colors import ListedColormap | ||
|
||
|
||
def make_custom_colormap(): | ||
""" | ||
Make a custom colormap for plotting. The colormap starts at 0.35 to ensure \ | ||
that there is a visual difference between 0 (no signal) and depleted (near-\ | ||
zero enrichment). | ||
Returns | ||
------- | ||
my_cmap : matplotlib colormap | ||
The colormap to use when plotting. | ||
""" | ||
depleted = plt.colormaps['RdGy_r'] | ||
enriched = plt.colormaps['bwr'] | ||
newcolors = np.concatenate([depleted(np.linspace(0.35, 0.5, 128)), enriched(np.linspace(0.5, 1, 128))]) | ||
my_cmap = ListedColormap(newcolors) | ||
return my_cmap |
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