Skip to content

Commit 63b9ee6

Browse files
committed
included tests for scatterplot and hexbin plot to ensure colorbar does not exclude x-axis label and tick-labels
1 parent 8c71f60 commit 63b9ee6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pandas/tests/plotting/test_frame.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,35 @@ def test_plot_scatter(self):
10301030
axes = df.plot(x='x', y='y', kind='scatter', subplots=True)
10311031
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))
10321032

1033+
@pytest.mark.slow
1034+
def test_if_scatterplot_colorbar_affects_xaxis_visibility(self):
1035+
random_array = np.random.random((1000,3))
1036+
df = pd.DataFrame(random_array,columns=['A label','B label','C label'])
1037+
1038+
ax1 = df.plot.scatter(x='A label', y='B label')
1039+
ax2 = df.plot.scatter(x='A label', y='B label', c='C label')
1040+
1041+
assert all([vis[0].get_visible()==vis[1].get_visible() for vis in
1042+
zip(ax1.xaxis.get_minorticklabels(),ax2.xaxis.get_minorticklabels())]),\
1043+
'minor x-axis tick labels visibility changes when colorbar included'
1044+
assert all([vis[0].get_visible()==vis[1].get_visible() for vis in
1045+
zip(ax1.xaxis.get_majorticklabels(),ax2.xaxis.get_majorticklabels())]),\
1046+
'major x-axis tick labels visibility changes when colorbar included'
1047+
assert ax1.xaxis.get_label().get_visible()==ax2.xaxis.get_label().get_visible(),\
1048+
'x-axis label visibility changes when colorbar included'
1049+
1050+
@pytest.mark.slow
1051+
def test_if_hexbin_xaxis_label_is_visible(self):
1052+
random_array = np.random.random((1000,3))
1053+
df = pd.DataFrame(random_array,columns=['A label','B label','C label'])
1054+
1055+
ax = df.plot.hexbin('A label','B label', gridsize=12);
1056+
assert all([vis.get_visible() for vis in ax.xaxis.get_minorticklabels()]),\
1057+
'minor x-axis tick labels are not visible'
1058+
assert all([vis.get_visible() for vis in ax.xaxis.get_majorticklabels()]),\
1059+
'major x-axis tick labels are not visible'
1060+
assert ax.xaxis.get_label().get_visible(),'x-axis label is not visible'
1061+
10331062
@pytest.mark.slow
10341063
def test_plot_scatter_with_categorical_data(self):
10351064
# GH 16199

0 commit comments

Comments
 (0)