Repository: pandas-dev/pandas

Issue:
xlabel disappears in scatter plots with subplots and colorbar
This is related to this PR https://github.com/pandas-dev/pandas/pull/20446. Separating the subplot and single plots into two issues.

Copying from https://github.com/pandas-dev/pandas/pull/20446:

```
def make_multiplots(numrows=2,numcols=2,sharey=True,sharex=True,PATCH_MODE_FLAG = True, is_scatter = True):
    fig, axes = pl.subplots(numrows,numcols,sharey=sharey,sharex=sharex )
    for i in range(axes.shape[0]):
        for j in range(axes.shape[1]):
            random_array = np.random.random((1000,3))
            df = pd.DataFrame(random_array,columns=['A label','B label','C label'])
            if is_scatter:
                df.plot.scatter('A label','B label',c='C label', PATCH_MODE_FLAG = PATCH_MODE_FLAG,ax=axes[i,j]);
            else:
                df.plot.hexbin('A label','B label',gridsize=20, PATCH_MODE_FLAG = PATCH_MODE_FLAG,ax=axes[i,j]);
            
            
make_multiplots(numrows=2,numcols=2,sharey=True, sharex=True, PATCH_MODE_FLAG = False, is_scatter=True);pl.suptitle('pandas current version');            
make_multiplots(numrows=2,numcols=2,sharey=True, sharex=True, PATCH_MODE_FLAG = True, is_scatter=True);pl.suptitle('patch fixing x-axis');            
make_multiplots(numrows=2,numcols=2,sharey=True, sharex=True, PATCH_MODE_FLAG = False, is_scatter=False);pl.suptitle('pandas current version');            
make_multiplots(numrows=2,numcols=2,sharey=True, sharex=True, PATCH_MODE_FLAG = True, is_scatter=False);pl.suptitle('patch fixing x-axis');  
```          
![image](https://user-images.githubusercontent.com/26352146/37773292-97f0a5a2-2db3-11e8-9912-8f2f558f5740.png)
![image](https://user-images.githubusercontent.com/26352146/37773303-9eaa8e08-2db3-11e8-975b-ce454a33e277.png)
![image](https://user-images.githubusercontent.com/26352146/37773312-a30c9b62-2db3-11e8-9040-864b16ebf59a.png)
![image](https://user-images.githubusercontent.com/26352146/37773316-a6259916-2db3-11e8-9be2-592295972768.png)



Discussion:

Resolving patch:
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -847,7 +847,7 @@ def _plot_colorbar(self, ax, **kwds):
         # https://github.com/ipython/ipython/issues/11215
 
         img = ax.collections[0]
-        cbar = self.fig.colorbar(img, **kwds)
+        cbar = self.fig.colorbar(img, ax=ax, **kwds)
         points = ax.get_position().get_points()
         cbar_points = cbar.ax.get_position().get_points()
         cbar.ax.set_position([cbar_points[0, 0],


Test patch:
diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py
--- a/pandas/tests/plotting/test_frame.py
+++ b/pandas/tests/plotting/test_frame.py
@@ -1132,6 +1132,26 @@ def test_if_hexbin_xaxis_label_is_visible(self):
                     ax.xaxis.get_majorticklabels()])
         assert ax.xaxis.get_label().get_visible()
 
+    @pytest.mark.slow
+    def test_if_scatterplot_colorbars_are_next_to_parent_axes(self):
+        import matplotlib.pyplot as plt
+        random_array = np.random.random((1000, 3))
+        df = pd.DataFrame(random_array,
+                          columns=['A label', 'B label', 'C label'])
+
+        fig, axes = plt.subplots(1, 2)
+        df.plot.scatter('A label', 'B label', c='C label', ax=axes[0])
+        df.plot.scatter('A label', 'B label', c='C label', ax=axes[1])
+        plt.tight_layout()
+
+        points = np.array([ax.get_position().get_points()
+                           for ax in fig.axes])
+        axes_x_coords = points[:, :, 0]
+        parent_distance = axes_x_coords[1, :] - axes_x_coords[0, :]
+        colorbar_distance = axes_x_coords[3, :] - axes_x_coords[2, :]
+        assert np.isclose(parent_distance,
+                          colorbar_distance, atol=1e-7).all()
+
     @pytest.mark.slow
     def test_plot_scatter_with_categorical_data(self):
         # GH 16199