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
Unable to disable autoscaling in pyplot.plot #17955
Comments
Thanks for the clarification @QuLogic -- so the way to achieve the previous behavior would be to do something like this: plt.plot([0, 2], [0, 2], '-')
plt.gcf().canvas.draw()
plt.plot([0, 10], [1, 1], '-', scalex=False) The concept of delaying autoscaling makes sense to me, although in the example above the meaning of I'm not sure -- it could be that I'm just accustomed to the previous behavior. |
I guess what you really want is more along the lines of #15595? |
It seems like the fixes you bring up would address the issue in a reasonable way, triggering autoscaling when needed. |
Just a little poke: this bug is still open. Whether or not it results from an intentional change in #13593, it's not reflected in the documentation.
|
Good point. I think scalex/scaley should be deprecated in favor of #15595 once something like that gets in, but in the meantime the following seems to work OKish, going back to the old semantics: diff --git i/lib/matplotlib/axes/_axes.py w/lib/matplotlib/axes/_axes.py
index 5369eadbde..2b08537ef1 100644
--- i/lib/matplotlib/axes/_axes.py
+++ w/lib/matplotlib/axes/_axes.py
@@ -1719,6 +1719,8 @@ class Axes(_AxesBase):
additionally use any `matplotlib.colors` spec, e.g. full names
(``'green'``) or hex strings (``'#008000'``).
"""
+ if not scalex or not scaley:
+ self._unstale_viewLim()
kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
lines = [*self._get_lines(*args, data=data, **kwargs)]
for line in lines: (note that using scalex/scaley=False then implies some runtime cost, as explained in 160de56) |
Is there a better workaround than this? _xlim = ax.get_xlim()
ax.plot(x_big, y)
ax.set_xlim(_xlim) |
Bug report
Bug summary
Arguments to disable autoscaling are not working, so despite e.g.
scalex=False
the horizontal axis is re-scaled.Code for reproduction
Actual outcome
Output in-line in jupyter notebook:
Expected outcome
Expected autoscaling only for the first call, so the xscale is just a bit padded from [0, 2]. This works as expected in
matplotlib==3.1.3
:Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineTools installed with pip
The text was updated successfully, but these errors were encountered: