Skip to content

Commit be637d7

Browse files
author
Joseph Hamman
committed
bump min version of matplotlib to 1.5 (remove viridis colormap packaged in xarray)
1 parent 3b65a2a commit be637d7

File tree

6 files changed

+11
-286
lines changed

6 files changed

+11
-286
lines changed

ci/requirements-py35.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- distributed
99
- h5py
1010
- h5netcdf
11-
- matplotlib
11+
- matplotlib=1.5
1212
- netcdf4
1313
- pytest
1414
- flake8

doc/installing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ For plotting
4848
~~~~~~~~~~~~
4949

5050
- `matplotlib <http://matplotlib.org/>`__: required for :ref:`plotting`
51+
(1.5 or later)
5152
- `cartopy <http://scitools.org.uk/cartopy/>`__: recommended for
5253
:ref:`plot-maps`
5354
- `seaborn <https://stanford.edu/~mwaskom/software/seaborn/>`__: for better

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@
7171
tests_require=TESTS_REQUIRE,
7272
url=URL,
7373
packages=find_packages(),
74-
package_data={'xarray': ['tests/data/*', 'plot/default_colormap.csv']})
74+
package_data={'xarray': ['tests/data/*']})

xarray/plot/default_colormap.csv

Lines changed: 0 additions & 256 deletions
This file was deleted.

xarray/plot/utils.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,13 @@
33
import warnings
44

55
import numpy as np
6-
import pandas as pd
7-
import pkg_resources
86

97
from ..core.pycompat import basestring
108
from ..core.utils import is_scalar
119

1210
ROBUST_PERCENTILE = 2.0
1311

1412

15-
def _load_default_cmap(fname='default_colormap.csv'):
16-
"""
17-
Returns viridis color map
18-
"""
19-
from matplotlib.colors import LinearSegmentedColormap
20-
21-
# Not sure what the first arg here should be
22-
f = pkg_resources.resource_stream(__name__, fname)
23-
cm_data = pd.read_csv(f, header=None).values
24-
f.close()
25-
26-
return LinearSegmentedColormap.from_list('viridis', cm_data)
27-
28-
2913
def import_seaborn():
3014
'''import seaborn and handle deprecation of apionly module'''
3115
with warnings.catch_warnings(record=True) as w:
@@ -225,10 +209,6 @@ def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
225209
else:
226210
cmap = "viridis"
227211

228-
# Allow viridis before matplotlib 1.5
229-
if cmap == "viridis":
230-
cmap = _load_default_cmap()
231-
232212
# Handle discrete levels
233213
if levels is not None:
234214
if is_scalar(levels):

xarray/tests/test_plot.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def test_robust(self):
414414
cmap_params = _determine_cmap_params(self.data, robust=True)
415415
assert cmap_params['vmin'] == np.percentile(self.data, 2)
416416
assert cmap_params['vmax'] == np.percentile(self.data, 98)
417-
assert cmap_params['cmap'].name == 'viridis'
417+
assert cmap_params['cmap'] == 'viridis'
418418
assert cmap_params['extend'] == 'both'
419419
assert cmap_params['levels'] is None
420420
assert cmap_params['norm'] is None
@@ -498,7 +498,7 @@ def test_divergentcontrol(self):
498498
cmap_params = _determine_cmap_params(pos)
499499
assert cmap_params['vmin'] == 0
500500
assert cmap_params['vmax'] == 1
501-
assert cmap_params['cmap'].name == "viridis"
501+
assert cmap_params['cmap'] == "viridis"
502502

503503
# Default with negative data will be a divergent cmap
504504
cmap_params = _determine_cmap_params(neg)
@@ -510,17 +510,17 @@ def test_divergentcontrol(self):
510510
cmap_params = _determine_cmap_params(neg, vmin=-0.1, center=False)
511511
assert cmap_params['vmin'] == -0.1
512512
assert cmap_params['vmax'] == 0.9
513-
assert cmap_params['cmap'].name == "viridis"
513+
assert cmap_params['cmap'] == "viridis"
514514
cmap_params = _determine_cmap_params(neg, vmax=0.5, center=False)
515515
assert cmap_params['vmin'] == -0.1
516516
assert cmap_params['vmax'] == 0.5
517-
assert cmap_params['cmap'].name == "viridis"
517+
assert cmap_params['cmap'] == "viridis"
518518

519519
# Setting center=False too
520520
cmap_params = _determine_cmap_params(neg, center=False)
521521
assert cmap_params['vmin'] == -0.1
522522
assert cmap_params['vmax'] == 0.9
523-
assert cmap_params['cmap'].name == "viridis"
523+
assert cmap_params['cmap'] == "viridis"
524524

525525
# However, I should still be able to set center and have a div cmap
526526
cmap_params = _determine_cmap_params(neg, center=0)
@@ -550,17 +550,17 @@ def test_divergentcontrol(self):
550550
cmap_params = _determine_cmap_params(pos, vmin=0.1)
551551
assert cmap_params['vmin'] == 0.1
552552
assert cmap_params['vmax'] == 1
553-
assert cmap_params['cmap'].name == "viridis"
553+
assert cmap_params['cmap'] == "viridis"
554554
cmap_params = _determine_cmap_params(pos, vmax=0.5)
555555
assert cmap_params['vmin'] == 0
556556
assert cmap_params['vmax'] == 0.5
557-
assert cmap_params['cmap'].name == "viridis"
557+
assert cmap_params['cmap'] == "viridis"
558558

559559
# If both vmin and vmax are provided, output is non-divergent
560560
cmap_params = _determine_cmap_params(neg, vmin=-0.2, vmax=0.6)
561561
assert cmap_params['vmin'] == -0.2
562562
assert cmap_params['vmax'] == 0.6
563-
assert cmap_params['cmap'].name == "viridis"
563+
assert cmap_params['cmap'] == "viridis"
564564

565565

566566
@requires_matplotlib

0 commit comments

Comments
 (0)