-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move towards having get_shared_{x,y}_axes return immutable views. #21584
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
Conversation
Directly calling join() on the Groupers is not sufficient to share axes, anyways, so don't let users do that.
* when using latest stable matplotlib our testsuite produces hundreds of warnings like this: ``` tests/test_data_access_by_filesystem.py: 54 warnings tests/test_summary.py: 99 warnings /home/tyler/python_310_darshan_venv/lib/python3.10/site-packages/darshan/experimental/plots/data_access_by_filesystem.py:536: MatplotlibDeprecationWarning: The join function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. ax_filesystem_counts.get_shared_x_axes().join(ax_filesystem_counts, list_count_axes[row - 1]) ``` * this originates from this upstream PR: matplotlib/matplotlib#21584 * turn this warning into an error in our CI, to prevent further introductions of the deprecated functionality, and fix it up where we already use it, based on the directions in the PR above
Hmmmm, not sure about this now. What is the equivalent of |
I don't really want to support unsharing, see e.g. #15287 and especially #9923: the semantics are not trivial. PS: Feel free to re-ping me on old issues/prs if needed, I tend to unsubscribe from them once they are closed/merged. |
@anntzer I am running into an issue where I need the ability to unshare axes. I have been messing around with the api for a while to get it to work but can't seem to toggle the ticklabels back on. Is there some hacky way to get the ticklabels to behave independently again? This is what I was playing around with codeimport ultraplot as uplt
from matplotlib import cbook
import numpy as np
from matplotlib import ticker as mticker
from matplotlib.axis import Ticker
fig, ax = uplt.subplots(ncols = 2, nrows = 2, wspace = 5, hspace = 5)
# ax[0]._shared_axes["x"] = cbook.Grouper()
print(list(ax[0]._shared_axes.keys()))
data = np.random.rand(2, 100)
for axi in range(0, 4):
d = data + axi * 100
ax[axi].scatter(*d)
print(ax[0].xaxis.offsetText)
# print(ax[0].xaxis._ticks.
for idx in range(4):
axi = ax[idx]
axi._shared_axes["y"] = cbook.Grouper()
axi._shared_axes["x"] = cbook.Grouper()
axi._shared_axes["z"] = cbook.Grouper()
axi._shared_axes["view"] = cbook.Grouper()
for idx in range(4):
axi = ax[idx]
axi.xaxis.reset_ticks()
axi.yaxis.reset_ticks()
axi.xaxis.major = Ticker()
axi.yaxis.major = Ticker()
axi.yaxis.minor = Ticker()
axi.xaxis.minor = Ticker()
axi.xaxis._set_scale(uplt.scale.LinearScale())
axi.yaxis._set_scale(uplt.scale.LinearScale())
axi.xaxis.offsetText.set_visible(True)
axi.yaxis.offsetText.set_visible(True)
axi.xaxis.offsetText.set_text("hello world")
major_locs = axi.yaxis.get_majorticklocs()
major_ticks = axi.yaxis.get_major_ticks()
major_labels = axi.yaxis.major.formatter.format_ticks(major_locs)
axi.tick_params(
left = True,
# right = True,
bottom = True,
# top = True,
# labelleft = True,
# labelright = True,
# labelbottom = True,
# labeltop = True,
which = "both",
axis = "both",
)
print(axi.yaxis.get_tick_params())
for tick, loc, label in zip(major_ticks, major_locs, major_labels):
tick.update_position(loc)
tick.label1.set_text(label)
tick.label2.set_text(label)
axi.xaxis.set_major_locator(mticker.AutoLocator())
axi.xaxis.set_major_formatter(mticker.ScalarFormatter())
axi.xaxis.set_minor_locator(mticker.AutoMinorLocator())
axi.xaxis.set_minor_formatter(mticker.NullFormatter())
axi.yaxis.set_major_locator(mticker.AutoLocator())
axi.yaxis.set_minor_locator(mticker.AutoMinorLocator())
axi.xaxis.set_minor_formatter(mticker.NullFormatter())
axi.yaxis.set_major_formatter(mticker.ScalarFormatter())
axi.autoscale_view()
# ax[1].scatter(*data)
# for axj in axi:
# print(axj.number)/ any help would be appreciated! |
Unsharing is complicated to say the least, see e.g. #9923 |
@anntzer I read up on the issue spread across multiple pages on matplotlib. The one you listed is very helpful indeed. In my case I'm not interested in maintaining the transitive properties and merely would like to isolate the axes. I just can't figure out why the axes label behave so strangy. From the API I can see that we get shallow copy of the minor and major tickets which I believe I reset here. Is there a way to rebuild them that would achieve an axis isolation procedure? |
I don't have a quick reply available, you may have more luck opening a new issue to discuss your problem. |
Directly calling join() on the Groupers is not sufficient to share axes,
anyways, so don't let users do that.
See https://gitter.im/matplotlib/matplotlib?at=618bf31f9d20982e4f10df53.
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).