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
Right and top spine placement: set_position(('data', x)) puts the spine at x + 1 instead of x. #1960
Setting the location of the top and right spines to X is locating them at X +1. The left and bottom spines are placed as expected.
I posted this to the users list and it was verified by Goyo goyodiaz@gmail.com.
The following code demonstrates the error:
importmatplotlib.pyplotaspltf=plt.figure(1)
f.clf()
ax=plt.subplot(111)
# spine is located at x = -1.5ax.spines['left'].set_position(('data', -1.5))
# spine should be located at y = 0.5 but is placed at y = 1.5ax.spines['top'].set_position(('data',0.5))
# spine should be located at x = -0.5 but is placed at x = +0.5ax.spines['right'].set_position(('data',-0.5))
# spine is placed at y = 0.ax.spines['bottom'].set_position('zero')
ax.set_xlim([-2,2])
ax.set_ylim([-2,2])
plt.show()
The issue is coming because right and top splines are initialized with a path vertex of 1 instead of zero as follows (the 13 is a placeholder that is replaced when _adjust_location is called before drawing the spine):
Then when the affine spine transform is set it is offsets it by the amount you give. It seems to me the proper solution is to adjust the spine transform to handle right and top differently than left and bottom when the requested position is data offset. I have a patch for it and testcase ready if that is the way we want to go.
Activity
cimarronm commentedon Apr 30, 2013
The issue is coming because
rightandtopsplines are initialized with a path vertex of 1 instead of zero as follows (the 13 is a placeholder that is replaced when _adjust_location is called before drawing the spine):Then when the affine spine transform is set it is offsets it by the amount you give. It seems to me the proper solution is to adjust the spine transform to handle
rightandtopdifferently thanleftandbottomwhen the requested position is data offset. I have a patch for it and testcase ready if that is the way we want to go.Fixes issue matplotlib#1960. Account for right/top spine data offset …
Merge pull request #1964 from cimarronm/data_spine_right_top_location…
dmcdougall commentedon Jun 16, 2013
Fixed by #1964 so closing.