Re: [matplotlib-devel] Transforms bug

 Re: [matplotlib-devel] Transforms bug From: Phil Elson - 2012-08-27 18:48:26 Attachments: Message as HTML ```>>> right angles are no longer right angles: noob error. Apologies. Forgiven; on the basis that you provided such an entertainingly colourful initial report! :-) ```

 [matplotlib-devel] Transforms bug From: Damon McDougall - 2012-08-27 17:05:19 ```My cherubs, With my new found free time, I may have discovered a sneaky bug to which you are not aware. Unless, of course, my example code is incorrect. I do normal setup: from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas from matplotlib.figure import Figure from matplotlib.patches import Rectangle from matplotlib.transforms import Affine2D fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(1, 1, 1) # Make a sexy rectangle at the origin r = Rectangle((0.0, 0.0), 0.6, 0.4) # Construct a mind-blowing transformation: rotation by 30 degrees t = Affine2D().rotate_deg(30.0) # Make sure to add in the already-known axes data transformation t += ax.transData # Rotate that shizzle r.set_transform(t) # Plottify ax.add_patch(r) fig.savefig('my_awesome_TRAPEZIUM.pdf') Or you can look at my output here: http://i.imgur.com/2l439.png Rotation by 30 degrees is an angle-preserving linear transformation. So this shouldn't happen. Here's what's messing shiz up: the figure dimensions are not square. Look what happens when I use a square figure and make the axes fit exactly to the figure dimensions: ... fig = Figure((4, 4)) ... ax = fig.add_axes([0, 0, 1, 1]) ... ... fig.savefig('my_awesome_RECTANGLE.pdf') You can see the output here: http://i.imgur.com/baXiH.png Boom. I have no idea how to fix it. I came across it while trying to address https://github.com/matplotlib/matplotlib/issues/987 but it may or may not also be related to https://github.com/matplotlib/matplotlib/issues/1113 Let me know if it's worth putting in github issue. I'm dont want to create a duplicate ticket should it transpire that this problem is actually #1113 in disguise. Best, Damon -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom ```
 Re: [matplotlib-devel] Transforms bug From: Michael Droettboom - 2012-08-27 17:26:59 ```I'm not sure this is a bug. The transformation is being applied in data space, and then the mapping to physical space is not square in the x and y dimensions. I think calling set_aspect('equal') on the axes should fix this -- if it doesn't, that's indeed a bug. Mike On 08/27/2012 01:05 PM, Damon McDougall wrote: > My cherubs, > > With my new found free time, I may have discovered a sneaky bug to which > you are not aware. Unless, of course, my example code is incorrect. > > I do normal setup: > > from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas > from matplotlib.figure import Figure > from matplotlib.patches import Rectangle > from matplotlib.transforms import Affine2D > > fig = Figure() > canvas = FigureCanvas(fig) > ax = fig.add_subplot(1, 1, 1) > > # Make a sexy rectangle at the origin > r = Rectangle((0.0, 0.0), 0.6, 0.4) > > # Construct a mind-blowing transformation: rotation by 30 degrees > t = Affine2D().rotate_deg(30.0) > > # Make sure to add in the already-known axes data transformation > t += ax.transData > > # Rotate that shizzle > r.set_transform(t) > > # Plottify > ax.add_patch(r) > > fig.savefig('my_awesome_TRAPEZIUM.pdf') > > Or you can look at my output here: http://i.imgur.com/2l439.png > > Rotation by 30 degrees is an angle-preserving linear transformation. So > this shouldn't happen. > > Here's what's messing shiz up: the figure dimensions are not square. > Look what happens when I use a square figure and make the axes fit > exactly to the figure dimensions: > > ... > fig = Figure((4, 4)) > ... > ax = fig.add_axes([0, 0, 1, 1]) > ... > ... > fig.savefig('my_awesome_RECTANGLE.pdf') > > You can see the output here: http://i.imgur.com/baXiH.png > > Boom. > > I have no idea how to fix it. I came across it while trying to address > https://github.com/matplotlib/matplotlib/issues/987 but it may or may > not also be related to > https://github.com/matplotlib/matplotlib/issues/1113 > > Let me know if it's worth putting in github issue. I'm dont want to > create a duplicate ticket should it transpire that this problem is > actually #1113 in disguise. > > Best, > Damon > ```
 Re: [matplotlib-devel] Transforms bug From: Damon McDougall - 2012-08-27 17:35:02 ```On Mon, Aug 27, 2012 at 01:26:49PM -0400, Michael Droettboom wrote: > I'm not sure this is a bug. The transformation is being applied in data > space, and then the mapping to physical space is not square in the x and > y dimensions. > > I think calling set_aspect('equal') on the axes should fix this -- if it > doesn't, that's indeed a bug. > Awesome, it worked. Honestly, I probably should have realised that when you don't have square axes, right angles are no longer right angles: noob error. Apologies. > > Mike > > On 08/27/2012 01:05 PM, Damon McDougall wrote: > > My cherubs, > > > > With my new found free time, I may have discovered a sneaky bug to which > > you are not aware. Unless, of course, my example code is incorrect. > > > > I do normal setup: > > > > from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas > > from matplotlib.figure import Figure > > from matplotlib.patches import Rectangle > > from matplotlib.transforms import Affine2D > > > > fig = Figure() > > canvas = FigureCanvas(fig) > > ax = fig.add_subplot(1, 1, 1) > > > > # Make a sexy rectangle at the origin > > r = Rectangle((0.0, 0.0), 0.6, 0.4) > > > > # Construct a mind-blowing transformation: rotation by 30 degrees > > t = Affine2D().rotate_deg(30.0) > > > > # Make sure to add in the already-known axes data transformation > > t += ax.transData > > > > # Rotate that shizzle > > r.set_transform(t) > > > > # Plottify > > ax.add_patch(r) > > > > fig.savefig('my_awesome_TRAPEZIUM.pdf') > > > > Or you can look at my output here: http://i.imgur.com/2l439.png > > > > Rotation by 30 degrees is an angle-preserving linear transformation. So > > this shouldn't happen. > > > > Here's what's messing shiz up: the figure dimensions are not square. > > Look what happens when I use a square figure and make the axes fit > > exactly to the figure dimensions: > > > > ... > > fig = Figure((4, 4)) > > ... > > ax = fig.add_axes([0, 0, 1, 1]) > > ... > > ... > > fig.savefig('my_awesome_RECTANGLE.pdf') > > > > You can see the output here: http://i.imgur.com/baXiH.png > > > > Boom. > > > > I have no idea how to fix it. I came across it while trying to address > > https://github.com/matplotlib/matplotlib/issues/987 but it may or may > > not also be related to > > https://github.com/matplotlib/matplotlib/issues/1113 > > > > Let me know if it's worth putting in github issue. I'm dont want to > > create a duplicate ticket should it transpire that this problem is > > actually #1113 in disguise. > > > > Best, > > Damon > > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Matplotlib-devel mailing list > Matplotlib-devel@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom ```
 Re: [matplotlib-devel] Transforms bug From: Phil Elson - 2012-08-27 18:48:26 Attachments: Message as HTML ```>>> right angles are no longer right angles: noob error. Apologies. Forgiven; on the basis that you provided such an entertainingly colourful initial report! :-) ```