Skip to content

scatter plot and hexbin plot lose x-axis when colorbar is included. #20446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 85 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e2abff6
removed colorbars from _handle_shared_axes when called by scatterplot…
javadnoorb Mar 22, 2018
0ea226f
removed colorbars from _handle_shared_axes when called by scatterplot…
javadnoorb Mar 22, 2018
80f949f
added a debug global variable
javadnoorb Mar 22, 2018
8f52eab
removed whitespaces
javadnoorb Mar 22, 2018
215fb89
Update _core.py
javadnoorb Mar 28, 2018
7c6efe2
Update _core.py
javadnoorb Mar 28, 2018
8c71f60
Update _tools.py
javadnoorb Mar 29, 2018
63b9ee6
included tests for scatterplot and hexbin plot to ensure colorbar doe…
javadnoorb Mar 29, 2018
f401672
Update test_frame.py
javadnoorb Mar 29, 2018
b821474
Update test_frame.py
javadnoorb Mar 29, 2018
52c1fa8
Update _tools.py
javadnoorb Mar 29, 2018
edf008d
fixing assert message
javadnoorb Mar 29, 2018
db6cf67
Update test_frame.py
javadnoorb Mar 29, 2018
186a09c
fixing style issues
javadnoorb Mar 29, 2018
e6980f3
DOC: Improve the docstrings of CategoricalIndex.map (#20286)
l736x Mar 22, 2018
cdc0240
DOC: update the DataFrame.to_hdf() docstirng (#20186)
shelvinskyi Mar 22, 2018
4848dea
DOC: enable docstring on DataFrame.columns/index (#20385)
jorisvandenbossche Mar 22, 2018
5aed4b5
DOC: general docstring formatting fixes (#20449)
jorisvandenbossche Mar 22, 2018
e2053c9
parameterize tests in scalar/timedelta (#20428)
minggli Mar 22, 2018
268fcf6
API & BUG: allow list-like y argument to df.plot & fix integer arg to…
masongallo Mar 22, 2018
3a76199
Removed dead groupby code (#20457)
WillAyd Mar 22, 2018
189dd8e
EHN: allow zip compression in `to_pickle`, `to_json`, `to_csv` (#20394)
minggli Mar 22, 2018
c302b04
ENH: Sorting of ExtensionArrays (#19957)
TomAugspurger Mar 22, 2018
faefc89
DOC: Improve the docstring of DataFrame.transpose() (#20254)
igorcadelima Mar 23, 2018
4a77c96
DOC: Update pandas.Series.copy docstring (#20261)
thismakessand Mar 23, 2018
e03b4b8
DOC: update the pandas.DataFrame.plot.box docstring (#20373)
4kxz Mar 23, 2018
5ffb078
DOC: make deprecation warning more visible with red box (#20357)
Imanflow Mar 23, 2018
689b3fe
TST: clean deprecation warnings & some parametrizing (#20467)
jreback Mar 23, 2018
7f97c13
REF: Mock all S3 Tests (#20409)
TomAugspurger Mar 23, 2018
9dd5111
TST: Fixed version comparison (#20469)
TomAugspurger Mar 24, 2018
10db32e
TST: 32-bit compat for categorical factorization tests (#20482)
jreback Mar 25, 2018
c1cbd96
API: Preserve int columns in to_dict('index') (#20444)
reidy-p Mar 25, 2018
cfad93f
DOC: Fix broken dependency links (#20471)
tv3141 Mar 25, 2018
f3eaa55
DOC: update the pandas.Series.str.startswith docstring (#20458)
dcreekp Mar 25, 2018
daa3b33
BUG: dropna() on single column timezone-aware values (#13407) (#20422)
JQGoh Mar 25, 2018
40a91c5
TST: test_nanops some parametrize & catch warnings (RuntimeWarning: A…
jreback Mar 26, 2018
eecb129
ENH: DataFrame.pivot accepts a list of values (#18636)
ibrahimsharaf Mar 26, 2018
31f7dc2
BUG: raise error when setting cached properties (#20487)
jorisvandenbossche Mar 26, 2018
56ca9a3
DOC: update the DataFrame.stack docstring (#20430)
samuelsinayoko Mar 26, 2018
492130b
CI: Fixed deprecationWarning (#20489)
TomAugspurger Mar 26, 2018
f02b82b
DOC: update the isna, isnull, notna and notnull docstring (#20459)
Cheukting Mar 26, 2018
9778c85
CLN: remove deprecated infer_dst keyword (#20490)
jorisvandenbossche Mar 27, 2018
a346778
Parametrized NA sentinel for factorize (#20473)
TomAugspurger Mar 27, 2018
b4365e8
DEPR: deprecate get_ftype_counts (GH18243) (#20404)
GGordonGordon Mar 27, 2018
15b7138
DOC: update the Series.str.join docstring (#20463)
fdroessler Mar 27, 2018
b0143e5
ENH/API: ExtensionArray.factorize (#20361)
TomAugspurger Mar 27, 2018
e6c2945
DOC: update vendored numpydoc version
jorisvandenbossche Mar 16, 2018
d2e23f8
DOC: change to numpydoc: add option to use member listing for attributes
jorisvandenbossche Mar 16, 2018
91e5e6b
DOC: change to numpydoc: use isdatadescriptor instead of isgetsetdesc…
jorisvandenbossche Mar 27, 2018
4c6688d
DOC: use numpydoc_use_blockquotes=False for compatibility
jorisvandenbossche Mar 16, 2018
3e91555
DOC: docstring to series.unique (#20474)
minggli Mar 23, 2018
71dff0d
DOC: add guide on shared docstrings (#20016)
TomAugspurger Mar 28, 2018
72524e8
Set pd.options.display.max_columns=0 by default (#17023)
cbrnr Mar 28, 2018
fd08b9f
DOC: whatsnew edits
jreback Mar 28, 2018
3549eca
ENH: Support ExtensionArray in Groupby (#20502)
TomAugspurger Mar 28, 2018
223ae0a
DOC: update the pandas.Series.str.endswith docstring (#20491)
dcreekp Mar 28, 2018
f067b47
DOC: Improving the docstring of Series.str.upper and related (#20462)
Hamishpk Mar 28, 2018
aa1dbd2
DOC: update the Series.between docstring (#20443)
mrw34 Mar 28, 2018
86f17cb
CLN: Removed not necessary bn switch decorator on nansum (#20481)
Mar 29, 2018
3d47aec
DOC: Fix various warnings (#20509)
TomAugspurger Mar 29, 2018
0c3c723
DOC: whatsnew edits
jreback Mar 29, 2018
145d75c
DOC: Add comparison with Stata page to documentation (#19945)
kylebarron Mar 29, 2018
64a2a55
DOC: Update missing_data.rst (#20424)
pulkitmaloo Mar 29, 2018
41cdfdc
Update v0.23.0.txt
javadnoorb Mar 29, 2018
c8ff378
Merge branch 'master' into master
javadnoorb Mar 29, 2018
48291ef
Update test_frame.py
javadnoorb Mar 29, 2018
09c7636
remove whitespace
javadnoorb Mar 30, 2018
864420b
Inline backend (#2)
javadnoorb Apr 10, 2018
eb123be
Update _tools.py
javadnoorb Apr 10, 2018
1fb4eec
Update _core.py
javadnoorb Apr 10, 2018
0397999
Update _core.py
javadnoorb Apr 10, 2018
5ba105f
Update v0.23.0.txt
javadnoorb Apr 10, 2018
ad1b495
Update _core.py
javadnoorb Apr 10, 2018
bdc7f5a
Inline backend - fixing colorbar axis position roundoff error locally
javadnoorb Apr 13, 2018
e656f6e
broken merge
javadnoorb Apr 13, 2018
1e4efd3
Merge remote-tracking branch 'upstream/master'
javadnoorb Apr 23, 2018
45aea6f
Merge remote-tracking branch 'upstream/master'
javadnoorb Apr 24, 2018
eeb6a9f
update fork
javadnoorb Jun 30, 2018
a802ecf
refactoring
javadnoorb Jun 30, 2018
8d766ae
refactoring
javadnoorb Jun 30, 2018
4f380b2
updating whatsnew docs
javadnoorb Jun 30, 2018
04ff768
updating whatsnew docs
javadnoorb Jun 30, 2018
8c0f2e5
updating whatsnew docs
javadnoorb Jun 30, 2018
564790f
updating whatsnew docs
javadnoorb Jun 30, 2018
7196d6e
added more comments
javadnoorb Jul 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ Plotting
- Bug in formatting tick labels with ``datetime.time()`` and fractional seconds (:issue:`18478`).
- :meth:`Series.plot.kde` has exposed the args ``ind`` and ``bw_method`` in the docstring (:issue:`18461`). The argument ``ind`` may now also be an integer (number of sample points).
- :func:`DataFrame.plot` now supports multiple columns to the ``y`` argument (:issue:`19699`)

- Bug in :func:'DataFrame.plot.scatter' and :func:'DataFrame.plot.hexbin' caused x-axis label and ticklabels to disappear when colorbar was on in IPython inline backend (:issue:`10611` and :issue:`10678`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to 0.24.0


Groupby/Resample/Rolling
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
17 changes: 14 additions & 3 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,13 @@ def _make_plot(self):
kws = dict(ax=ax)
if self.mpl_ge_1_3_1():
kws['label'] = c if c_is_column else ''
self.fig.colorbar(img, **kws)

cbar = self.fig.colorbar(img, **kws)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe refactor this and https://github.com/pandas-dev/pandas/pull/20446/files#diff-2b118bda866f3d626ceb6b529c62cd1aR932 to a method. They're identical, right? I guess aside from **kws vs. ax=ax?

points = ax.get_position().get_points()
cbar_points = cbar.ax.get_position().get_points()
cbar.ax.set_position([cbar_points[0, 0],
points[0, 1],
cbar_points[1, 0] - cbar_points[0, 0],
points[1, 1] - points[0, 1]])
if label is not None:
self._add_legend_handle(scatter, label)
else:
Expand Down Expand Up @@ -924,7 +929,13 @@ def _make_plot(self):
**self.kwds)
if cb:
img = ax.collections[0]
self.fig.colorbar(img, ax=ax)
cbar = self.fig.colorbar(img, ax=ax)
points = ax.get_position().get_points()
cbar_points = cbar.ax.get_position().get_points()
cbar.ax.set_position([cbar_points[0, 0],
points[0, 1],
cbar_points[1, 0] - cbar_points[0, 0],
points[1, 1] - points[0, 1]])

def _make_legend(self):
pass
Expand Down
43 changes: 43 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,49 @@ def test_plot_scatter(self):
axes = df.plot(x='x', y='y', kind='scatter', subplots=True)
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))

@pytest.mark.slow
def test_if_scatterplot_colorbar_affects_xaxis_visibility(self):
# addressing issue #10611, to ensure colobar does not
# interfere with x-axis label and ticklabels with
# ipython inline backend.
random_array = np.random.random((1000, 3))
df = pd.DataFrame(random_array,
columns=['A label', 'B label', 'C label'])

ax1 = df.plot.scatter(x='A label', y='B label')
ax2 = df.plot.scatter(x='A label', y='B label', c='C label')

vis1 = [vis.get_visible() for vis in
ax1.xaxis.get_minorticklabels()]
vis2 = [vis.get_visible() for vis in
ax2.xaxis.get_minorticklabels()]
assert vis1 == vis2

vis1 = [vis.get_visible() for vis in
ax1.xaxis.get_majorticklabels()]
vis2 = [vis.get_visible() for vis in
ax2.xaxis.get_majorticklabels()]
assert vis1 == vis2

assert (ax1.xaxis.get_label().get_visible() ==
ax2.xaxis.get_label().get_visible())

@pytest.mark.slow
def test_if_hexbin_xaxis_label_is_visible(self):
# addressing issue #10678, to ensure colobar does not
# interfere with x-axis label and ticklabels with
# ipython inline backend.
random_array = np.random.random((1000, 3))
df = pd.DataFrame(random_array,
columns=['A label', 'B label', 'C label'])

ax = df.plot.hexbin('A label', 'B label', gridsize=12)
assert all([vis.get_visible() for vis in
ax.xaxis.get_minorticklabels()])
assert all([vis.get_visible() for vis in
ax.xaxis.get_majorticklabels()])
assert ax.xaxis.get_label().get_visible()

@pytest.mark.slow
def test_plot_scatter_with_categorical_data(self):
# GH 16199
Expand Down