Repository: geopandas/geopandas

Issue:
BUG: categories passed as a series are not properly sorted
If you pass a series of categories to plot, those are used directly as an array, even though the series might have an index of a different order than df. See the example below.

```python
from shapely.geometry import Point
import pandas as pd

pts = [Point(x, x) for x in range(10)]
df = gpd.GeoDataFrame(geometry=pts)

# this is correct, since gdf.index and colors.index are in the same order
colors = pd.Series(['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a'])
df.plot(colors, legend=True)
```
![image](https://user-images.githubusercontent.com/36797143/94190673-54dbbd00-fea4-11ea-865d-845bd77ad929.png)

```python
# I would assume that this gets sorted based on the index first, but it does not - the index is ignored
colors_ord = pd.Series(['a', 'a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'], index=[0, 3, 6, 9, 1, 4, 7, 2, 5, 8])
df.plot(colors_ord, legend=True)
```
![image](https://user-images.githubusercontent.com/36797143/94190771-789f0300-fea4-11ea-9fc3-b23a11caf568.png)

```python
# if you assign the same series as a column before plotting, it works properly
df['colors_ord'] = colors_ord
df.plot('colors_ord', legend=True)
```
![image](https://user-images.githubusercontent.com/36797143/94190841-90768700-fea4-11ea-9320-9c63fab23a63.png)

I would say that in these cases, we should check the index first and sort it properly before using values.

Discussion:
nickhand: 👋 @jdmcbr !! Great to see you doing some cool stuff!

Patch:
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
index 8edd02a8..41e5fede 100644
--- a/geopandas/plotting.py
+++ b/geopandas/plotting.py
@@ -636,6 +636,10 @@ def plot_dataframe(
             )
         else:
             values = column
+
+            # Make sure index of a Series matches index of df
+            if isinstance(values, pd.Series):
+                values = values.reindex(df.index)
     else:
         values = df[column]
 


Test patch:
diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py
index 7102dddc..03b889a9 100644
--- a/geopandas/tests/test_plotting.py
+++ b/geopandas/tests/test_plotting.py
@@ -86,6 +86,43 @@ class TestPointPlotting:
         expected_colors = cmap(np.arange(self.N) / (self.N - 1))
         _check_colors(self.N, ax.collections[0].get_facecolors(), expected_colors)
 
+    def test_series_color_no_index(self):
+
+        # Color order with ordered index
+        colors_ord = pd.Series(["a", "b", "c", "a", "b", "c", "a", "b", "c", "a"])
+
+        # Plot using Series as color
+        ax1 = self.df.plot(colors_ord)
+
+        # Correct answer: Add as column to df and plot
+        self.df["colors_ord"] = colors_ord
+        ax2 = self.df.plot("colors_ord")
+
+        # Confirm out-of-order index re-sorted
+        point_colors1 = ax1.collections[0].get_facecolors()
+        point_colors2 = ax2.collections[0].get_facecolors()
+        np.testing.assert_array_equal(point_colors1[1], point_colors2[1])
+
+    def test_series_color_index(self):
+
+        # Color order with out-of-order index
+        colors_ord = pd.Series(
+            ["a", "a", "a", "a", "b", "b", "b", "c", "c", "c"],
+            index=[0, 3, 6, 9, 1, 4, 7, 2, 5, 8],
+        )
+
+        # Plot using Series as color
+        ax1 = self.df.plot(colors_ord)
+
+        # Correct answer: Add as column to df and plot
+        self.df["colors_ord"] = colors_ord
+        ax2 = self.df.plot("colors_ord")
+
+        # Confirm out-of-order index re-sorted
+        point_colors1 = ax1.collections[0].get_facecolors()
+        point_colors2 = ax2.collections[0].get_facecolors()
+        np.testing.assert_array_equal(point_colors1[1], point_colors2[1])
+
     def test_colormap(self):
 
         # without specifying values but cmap specified -> no uniform color