Repository: pandas-dev/pandas

Issue:
bar-plots with wrong color using Matplotlib 1.5
Hi there,

I'm not sure if this is a pandas/matplotlib or seaborn issue...but since I upgraded to Matplotlib 1.5 using anaconda I can't get the colors of my barplots right anymore, here's an example:

In ipython notebook:

```
import pandas as pd

%matplotlib inline

import seaborn as sns
sns.set_style('whitegrid')

# Works, color as expected in nice muted blue
pd.DataFrame([1,2,3,4,5,6]).plot(linewidth=10)


# Doesn't work, getting matplotlib "eye-cancer-blue"
pd.DataFrame([1,2,3,4,5,6]).plot(kind='bar')
```

I attached a screenshot one with matplotlib 1.4.x and one with 1.5:

![matplotlib_15](https://cloud.githubusercontent.com/assets/10881376/11185937/8f124a62-8c7f-11e5-9d8f-56991ffdc798.png)
![matplotlib_14](https://cloud.githubusercontent.com/assets/10881376/11185936/8f11b7c8-8c7f-11e5-8773-8dceaea7bd76.png)

Again I know this might well not be a pandas issue but maybe someone has an idea where the problem might be.



Discussion:
probably a pandas issue since `plt.bar(df.index, df[0])` gives the correct colors.

hi, 
just to say the issue is still there in 0.17.1


Resolving patch:
diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py
--- a/pandas/tools/plotting.py
+++ b/pandas/tools/plotting.py
@@ -163,8 +163,11 @@ def _get_standard_colors(num_colors=None, colormap=None, color_type='default',
         if color_type == 'default':
             # need to call list() on the result to copy so we don't
             # modify the global rcParams below
-            colors = list(plt.rcParams.get('axes.color_cycle',
-                                           list('bgrcmyk')))
+            try:
+                colors = [c['color'] for c in list(plt.rcParams['axes.prop_cycle'])]
+            except KeyError:
+                colors = list(plt.rcParams.get('axes.color_cycle',
+                                               list('bgrcmyk')))
             if isinstance(colors, compat.string_types):
                 colors = list(colors)
         elif color_type == 'random':


Test patch:
diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py
--- a/pandas/tests/test_graphics.py
+++ b/pandas/tests/test_graphics.py
@@ -3716,6 +3716,24 @@ def test_plain_axes(self):
         Series(rand(10)).plot(ax=ax)
         Series(rand(10)).plot(ax=iax)
 
+    def test_passed_bar_colors(self):
+        import matplotlib as mpl
+        color_tuples = [(0.9, 0, 0, 1), (0, 0.9, 0, 1), (0, 0, 0.9, 1)] 
+        colormap = mpl.colors.ListedColormap(color_tuples)
+        barplot = pd.DataFrame([[1,2,3]]).plot(kind="bar", cmap=colormap)
+        self.assertEqual(color_tuples, [c.get_facecolor() for c in barplot.patches])
+
+    def test_rcParams_bar_colors(self):
+        import matplotlib as mpl
+        color_tuples = [(0.9, 0, 0, 1), (0, 0.9, 0, 1), (0, 0, 0.9, 1)]
+        try: # mpl 1.5
+            with mpl.rc_context(rc={'axes.prop_cycle': mpl.cycler("color", color_tuples)}):
+                barplot = pd.DataFrame([[1,2,3]]).plot(kind="bar")
+        except (AttributeError, KeyError): # mpl 1.4
+            with mpl.rc_context(rc={'axes.color_cycle': color_tuples}):
+                barplot = pd.DataFrame([[1,2,3]]).plot(kind="bar")
+        self.assertEqual(color_tuples, [c.get_facecolor() for c in barplot.patches])
+
 
 @tm.mplskip
 class TestDataFrameGroupByPlots(TestPlotBase):
@@ -3763,7 +3781,6 @@ def test_plot_submethod_works(self):
         df.groupby('z')['x'].plot.line()
         tm.close()
 
-
 def assert_is_valid_plot_return_object(objs):
     import matplotlib.pyplot as plt
     if isinstance(objs, np.ndarray):