From 19e3cc14f781e21b39aef6adc3cc7c3bc91a4cfa Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sat, 18 Aug 2018 12:56:45 -0700 Subject: [PATCH] =?UTF-8?q?Backport=20PR=20#11876:=20MAINT=20Better=20erro?= =?UTF-8?q?r=20message=20for=20number=20of=20colors=20versus=20number=20of?= =?UTF-8?q?=20data=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/matplotlib/axes/_axes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index ccccae9db634..ed7552418ae7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6537,7 +6537,10 @@ def hist(self, x, bins=None, range=None, density=None, weights=None, else: color = mcolors.to_rgba_array(color) if len(color) != nx: - raise ValueError("color kwarg must have one color per dataset") + error_message = ( + "color kwarg must have one color per data set. %d data " + "sets and %d colors were provided" % (len(color), nx)) + raise ValueError(error_message) # If bins are not specified either explicitly or via range, # we need to figure out the range required for all datasets,