The attached script demonstrates several bugs that are all related to the Axes
class. Areas affected are:
* Autoscaling
* Ellipse
* Inverting Axis objects
* Fixed aspect ratio
1) Auto scaling is not enacted when adding a Patch to an axes (more of a
feature)
2) When manually calling axes.autoscale_view(), the boundaries of an Ellipse
are incorrectly computed as they do not take into
account the rotation of the ellipse.
3) Inverting the axes using the current method of reversing the axes limits
does not always take effect right away. An explicit
call to axes.apply_aspect() fixes this.
4) When the axes are inverted and an Ellipse is rendered, then it becomes
asymptotic and not an ellipse.
5) When the axes are inverted and axes.set_aspect('equal', 'datalim') has been
called, then resizing the plot window will result in
the axes reverting back to their original state.
When it comes to handling inverted axes I have a proposition on how to better
handle this. It seems like every other month a user
asks the question how to do this and perhaps there should be a direct interface
to do so. Something like the following...
axes.invert_xaxis()
axes.invert_yaxis()
Each method would set a flag on the corresponding Axis object and all calls to
'axes.set_xlim' & 'axes.set_ylim' would check the
appropriate flag and automatically set the values in the correct order.
Additionally all calls to 'axes.get_xlim' and
'axes.get_ylim' would return the values in min, max order. I believe that an
interface like this would greatly simplify things for
both the user and the maintainer of the internal code (no need to put in checks
to see if the axes have been inverted). A simple
'axes.xaxis_inverted' or 'axes.yaxis_inverted' call would be sufficient to
determine if the axes have been inverted (for those users
who would need to check).
from pylab import *
from matplotlib.patches import Ellipse
delta = 45.0 # degrees
angles = arange(0, 360+delta, delta)
ells = [Ellipse((1, 1), 4, 2, a) for a in angles]
a = subplot(111, aspect='equal')
#BUG 1792567: Setting the autoscale to on does nothing when plotting a patch
a.set_autoscale_on(True)
# set the aspect ratio
a.set_aspect("equal", "datalim")
for e in ells:
e.set_alpha(0.1)
a.add_patch(e)
# Since autoscale does not work for patches we call manually
a.autoscale_view()
# put this here to force the axes to flush whatever caching it is is doing
# so that we can actually invert the axes
a.apply_aspect()
#BUG 1792575: Once the autoscale happens, it doesn't take into account
# the rotation value of an ellipse for calculating the view limits.
#BUG 1792599: Inverting the y-axis does nothing regardless of calling it before
# or after 'a.autoscale_view()
ymin, ymax = a.get_ylim()
a.set_ylim(ymax, ymin)
#BUG 1792603: Inverting the y-axis causes the rendered ellipse to be asymptotic.
show()
#BUG 1792615: Resizing the figure window with winverted axes looses the
inversion.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel