From 6ba084faf3c2a27466d054b8f93a209bb24e9d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Schl=C3=BCter?= Date: Thu, 24 May 2012 00:00:38 +0200 Subject: [PATCH 1/2] pyplot: Restored documented behaviour of set_cmap --- lib/matplotlib/pyplot.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index cbb49a94a999..a9a59890a5a9 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1742,8 +1742,6 @@ def set_cmap(cmap): if im is not None: im.set_cmap(cmap) - else: - raise RuntimeError('You must first define an image, eg with imshow') draw_if_interactive() From 7e9cc51129b66ac44d2e0b48540e9d8715c6b8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Schl=C3=BCter?= Date: Thu, 24 May 2012 00:02:55 +0200 Subject: [PATCH 2/2] pyplot: Added implementation comments to set_cmap --- lib/matplotlib/pyplot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index a9a59890a5a9..445952f51847 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1737,9 +1737,11 @@ def set_cmap(cmap): ''' cmap = cm.get_cmap(cmap) + # set the default colormap rc('image', cmap=cmap.name) + + # apply to current image if any im = gci() - if im is not None: im.set_cmap(cmap)