Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib bug in imshow (probably fixed in new version) #2900

Closed
sagetrac-cwitty mannequin opened this issue Apr 12, 2008 · 9 comments
Closed

matplotlib bug in imshow (probably fixed in new version) #2900

sagetrac-cwitty mannequin opened this issue Apr 12, 2008 · 9 comments

Comments

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Apr 12, 2008

Sage's current version of matplotlib has a bug, as reported by Fabio Tonti (http://groups.google.com/group/sage-support/browse_thread/thread/a41e9ab2b158c41e#):

sage: from pylab import *
sage: imshow([[(0,0,0)]])
sage: savefig('foo.png')
Traceback (most recent call last):
...
NameError: global name 'npy' is not defined 

It looks like this bug has been fixed in 0.91.2 (although I haven't actually tried it); we should upgrade.

CC: @jhpalmieri @jasongrout

Component: packages: standard

Author: Karl-Dieter Crisman

Reviewer: Jason Grout

Merged: sage-4.2.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/2900

@sagetrac-cwitty sagetrac-cwitty mannequin added this to the sage-4.1.2 milestone Apr 12, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Dec 2, 2008

comment:1

This still fails with Sage 3.2.1.rc1 (which ships with matplotlib 0.98.3):

sage: savefig('foo.png')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/scratch/mabshoff/release-cycle/sage-3.2.1.final/<ipython console> in <module>()

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/pyplot.pyc in savefig(*args, **kwargs)
    340 def savefig(*args, **kwargs):
    341     fig = gcf()
--> 342     return fig.savefig(*args, **kwargs)
    343 if Figure.savefig.__doc__ is not None:
    344     savefig.__doc__ = dedent(Figure.savefig.__doc__)

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)
    962                 patch.set_alpha(0.0)
    963 
--> 964         self.canvas.print_figure(*args, **kwargs)
    965 
    966         if transparent:

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   1308                 edgecolor=edgecolor,
   1309                 orientation=orientation,
-> 1310                 **kwargs)
   1311         finally:
   1312             self.figure.dpi = origDPI

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    303 
    304     def print_png(self, filename_or_obj, *args, **kwargs):
--> 305         FigureCanvasAgg.draw(self)
    306         renderer = self.get_renderer()
    307         original_dpi = renderer.dpi

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    259 
    260         self.renderer = self.get_renderer()
--> 261         self.figure.draw(self.renderer)
    262 
    263     def get_renderer(self):

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/figure.pyc in draw(self, renderer)
    757 
    758         # render the axes
--> 759         for a in self.axes: a.draw(renderer)
    760 
    761         # render the figure text

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe)
   1463         if len(self.images)<=1 or renderer.option_image_nocomposite():
   1464             for im in self.images:
-> 1465                 im.draw(renderer)
   1466         else:
   1467             # make a composite image blending alpha

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/image.pyc in draw(self, renderer, *args, **kwargs)
    234             self.axes.get_yscale() != 'linear'):
    235             warnings.warn("Images are not supported on non-linear axes.")
--> 236         im = self.make_image(renderer.get_image_magnification())
    237         l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
    238         renderer.draw_image(round(l), round(b), im, self.axes.bbox.frozen(),

/scratch/mabshoff/release-cycle/sage-3.2.1.final/local/lib/python2.5/site-packages/matplotlib/image.pyc in make_image(self, magnification)
    185                 else:
    186                     x = self._rgbacache
--> 187                 im = _image.fromarray(x[yslice,xslice], 0)
    188                 if len(self._A.shape) == 2:
    189                     im.is_grayscale = self.cmap.is_gray()

ValueError: Array must be rank 2 or 3 of doubles
sage: 
Exiting SAGE (CPU time 0m1.32s, Wall time 0m43.85s).

Cheers,

Michael

@kcrisman
Copy link
Member

comment:2

To release manager:
This is now fixed, given #5448 (and perhaps long before that):

sage: from pylab import *
sage: imshow([[(0,0,0)]])
<matplotlib.image.AxesImage object at 0xa50f190>
sage: savefig('foo.png')

foo.png is attached.

@kcrisman
Copy link
Member

Attachment: foo.png

@kcrisman
Copy link
Member

Depends on #7059

@kcrisman
Copy link
Member

comment:3

Attachment: trac_2900-imshow-save.patch.gz

The patch verifies this is fixed, and uses the new (better) syntax from #7059.

@kcrisman
Copy link
Member

Author: Karl-Dieter Crisman

@jasongrout
Copy link
Member

comment:5

Thanks for making a doctest patch.

@mwhansen
Copy link
Contributor

Merged: sage-4.2.alpha0

@mwhansen
Copy link
Contributor

Reviewer: Jason Grout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants