Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: fix deprecation warnings from matplotlib #79

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ So, for example, if one were to use the *rainforest* colormap, this could be don
import cmasher as cmr

# Import packages for plotting
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

# Access rainforest colormap through CMasher or MPL
cmap = cmr.rainforest # CMasher
cmap = plt.get_cmap('cmr.rainforest') # MPL
cmap = mpl.colormaps['cmr.rainforest'] # MPL

# Generate some data to plot
x = np.random.rand(100)
Expand Down
3 changes: 1 addition & 2 deletions cmasher/cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Package imports
import matplotlib as mpl
import numpy as np
from matplotlib import cm as mplcm

import cmasher as cmr

Expand Down Expand Up @@ -240,7 +239,7 @@ def cli_lang_usage_r():
def get_cmap(cmap):
# Try to obtain the colormap from MPL
try:
cmap = mplcm.get_cmap(cmap)
cmap = mpl.colormaps.get_cmap(cmap)

# If this does not work, try to expand given cmap in setuptools-style
except ValueError:
Expand Down
6 changes: 3 additions & 3 deletions cmasher/colormaps/amber/amber.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/amethyst/amethyst.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/apple/apple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/arctic/arctic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/bubblegum/bubblegum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/chroma/chroma.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
10 changes: 5 additions & 5 deletions cmasher/colormaps/copper/copper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -536,8 +536,8 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)

# Shift the entire colormap by half of its length
cm_data_s = list(cm_data[255:])
Expand All @@ -548,5 +548,5 @@
cmap_s_r = cmap_s.reversed()

# Register shifted versions in MPL as well
register_cmap(cmap=cmap_s)
register_cmap(cmap=cmap_s_r)
mpl.colormaps.register(cmap=cmap_s)
mpl.colormaps.register(cmap=cmap_s_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/cosmic/cosmic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/dusk/dusk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/eclipse/eclipse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/ember/ember.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/emerald/emerald.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
10 changes: 5 additions & 5 deletions cmasher/colormaps/emergency/emergency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -536,8 +536,8 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)

# Determine central value index of the colormap
idx = len(cm_data) // 2
Expand All @@ -551,5 +551,5 @@
cmap_s_r = cmap_s.reversed()

# Register shifted versions in MPL as well
register_cmap(cmap=cmap_s)
register_cmap(cmap=cmap_s_r)
mpl.colormaps.register(cmap=cmap_s)
mpl.colormaps.register(cmap=cmap_s_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/fall/fall.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/flamingo/flamingo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/freeze/freeze.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/fusion/fusion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -537,5 +537,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/gem/gem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/ghostlight/ghostlight.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/gothic/gothic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -282,5 +282,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
6 changes: 3 additions & 3 deletions cmasher/colormaps/guppy/guppy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# %% IMPORTS
# Package imports
from matplotlib.cm import register_cmap
import matplotlib as mpl
from matplotlib.colors import ListedColormap

# All declaration
Expand Down Expand Up @@ -537,5 +537,5 @@
cmap_r = cmap.reversed()

# Register (reversed) cmap in MPL
register_cmap(cmap=cmap)
register_cmap(cmap=cmap_r)
mpl.colormaps.register(cmap=cmap)
mpl.colormaps.register(cmap=cmap_r)
Loading
Loading