Repository: geopandas/geopandas

Issue:
BUG: UnboundLocalError when missing_kwds is used
I'm afraid the issue isn't completely solved yet. Still (0.9.0, 0.10.2) getting the following error  

<img width="709" alt="Bildschirmfoto 2021-11-01 um 18 21 00" src="https://user-images.githubusercontent.com/4449821/139724524-68bd0d0d-ad1c-405e-af3a-cb1f46155371.png">  

however, if I apply your fix a second time a little later in the code like this  

<img width="641" alt="Bildschirmfoto 2021-11-01 um 18 21 58" src="https://user-images.githubusercontent.com/4449821/139724615-f0264f23-76d2-4029-bbe7-4740d428f153.png">

it plots as expected – should you need a testcase pls let me know and thanks so far

_Originally posted by @wahlatlas in https://github.com/geopandas/geopandas/issues/1600#issuecomment-956497381_

Discussion:

Patch:
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
index e17a4a3a..ba6ef8ae 100644
--- a/geopandas/plotting.py
+++ b/geopandas/plotting.py
@@ -860,7 +860,8 @@ GON (((-122.84000 49.00000, -120.0000...
             **style_kwds,
         )
 
-    if missing_kwds is not None and not expl_series[nan_idx].empty:
+    missing_data = not expl_series[nan_idx].empty
+    if missing_kwds is not None and missing_data:
         if color:
             if "color" not in missing_kwds:
                 missing_kwds["color"] = color
@@ -902,7 +903,7 @@ GON (((-122.84000 49.00000, -120.0000...
                         markeredgewidth=0,
                     )
                 )
-            if missing_kwds is not None:
+            if missing_kwds is not None and missing_data:
                 if "color" in merged_kwds:
                     merged_kwds["facecolor"] = merged_kwds["color"]
                 patches.append(


Test patch:
diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py
index d1d88519..55016870 100644
--- a/geopandas/tests/test_plotting.py
+++ b/geopandas/tests/test_plotting.py
@@ -404,7 +404,7 @@ class TestPointPlotting:
         ):
             self.df.plot(column="cats", categories=["cat1"])
 
-    def test_misssing(self):
+    def test_missing(self):
         self.df.loc[0, "values"] = np.nan
         ax = self.df.plot("values")
         cmap = plt.get_cmap()
@@ -428,6 +428,12 @@ class TestPointPlotting:
         np.testing.assert_array_equal(point_colors[0], leg_colors[0])
         np.testing.assert_array_equal(nan_color[0], leg_colors1[0])
 
+    def test_no_missing_and_missing_kwds(self):
+        # GH2210
+        df = self.df.copy()
+        df["category"] = df["values"].astype("str")
+        df.plot("category", missing_kwds={"facecolor": "none"}, legend=True)
+
 
 class TestPointZPlotting:
     def setup_method(self):