Description
Originally discussed on Gitter with @WeatherGod .
Currently, there is no easy (i.e. public built-in) way to set the position of the ticks and labels of an axis in mplot3d, while with 2d plots, one can for example achieve this with:
ax.xaxis.set_ticks_position("top")
ax.xaxis.set_label_position("top")
It would be nice to be able to have a similar feature for mplot3d. The current situation is that the label of an axis is placed through a heuristic that selects a reasonable axis based on the orientation of the plot. One will call that behavior "auto" in what follows. The proposal is to introduce a possibility for fixed placement of ticks and labels. A naming scheme that could work (at least in my genuine view) is:
- x-axis: {"auto", "front", "back", "both"};
- y-axis: {"auto", "front", "back", "both"};
- z-axis: {"auto", "left", "right", "both"}.
As far as I can tell, this seems quite robust to any rotation that I could achieve when playing with a 3d plot. Defaulting to "auto" would preserve the current behavior, while introducing the other names could address the need expressed by some users to change it, for example in this SO thread (or even recently on the mailing-list) where the OP gets the behavior that they wants by accessing and setting a private attribute:
# [yada yada yada]
tmp_planes = zaxis._PLANES
if 'left' in self.sides_to_draw :
# draw zaxis on the left side
zaxis._PLANES = (tmp_planes[2], tmp_planes[3],
tmp_planes[0], tmp_planes[1],
tmp_planes[4], tmp_planes[5])
elif 'right' in self.sides_to_draw :
# draw zaxis on the right side
zaxis._PLANES = (tmp_planes[3], tmp_planes[2],
tmp_planes[1], tmp_planes[0],
tmp_planes[4], tmp_planes[5])
# [yada yada yada]
Edit: adapted a code snippet from the SO thread to avoid relying on an external URL too much