You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x axis inverts when using plot with negative y #300
This is part of the "standardized arguments" feature (see this link)... but unfortunately I did not document it! I'll add this to the docs in the next version.
I find that most of the time, when I have "reversed" dependent variable coordinates, I want that axis to be reversed too. So I think I'd prefer to keep this default behavior. In your example, you can use ax.format(xreverse=False) to reverse the axis back. Alternatively (this is currently not part of the public API) ax.plot(x_set, y_set, autoreverse=False) should also work. Might make that part of the public API in the future.
No problem. FYI the master branch now includes documentation on auto-reversing in the "1D plotting" and "2D plotting" sections, and auto-reversing is now automatically disabled whenever the axis limits were previously explicitly fixed with e.g. ax.format(xlim=xlim) or ax.set_xlim(xlim) (f34c12c).
Activity
dewinkelwaar commentedon Nov 2, 2021
Note that this issue doesn`t occur when using matplotlib
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.subplot()
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
ax.set_title('line plot A->B vs B->A')
ax.set_xlabel('x axis')
ax.set_ylabel('y axis')
ax.scatter(-1, 1, color="b")
ax.text(-1, 1, "A")
ax.scatter(1, -1, color="b")
ax.text(1, -1, "B")
#x_set = [-1, 1]
#y_set = [1, -1]
x_set = [1, -1]
y_set = [-1, 1]
ax.plot(x_set, y_set, color="r")
pplt.show()
lukelbd commentedon Nov 2, 2021
This is part of the "standardized arguments" feature (see this link)... but unfortunately I did not document it! I'll add this to the docs in the next version.
I find that most of the time, when I have "reversed" dependent variable coordinates, I want that axis to be reversed too. So I think I'd prefer to keep this default behavior. In your example, you can use
ax.format(xreverse=False)to reverse the axis back. Alternatively (this is currently not part of the public API)ax.plot(x_set, y_set, autoreverse=False)should also work. Might make that part of the public API in the future.dewinkelwaar commentedon Nov 3, 2021
Ok, I understand your point. Thanks for the reply
Add 'autoreverse' docs and disable when lims are fixed (closes #300)
lukelbd commentedon Nov 3, 2021
No problem. FYI the master branch now includes documentation on auto-reversing in the "1D plotting" and "2D plotting" sections, and auto-reversing is now automatically disabled whenever the axis limits were previously explicitly fixed with e.g.
ax.format(xlim=xlim)orax.set_xlim(xlim)(f34c12c).