Skip to content

a matrix plot is wrong when matrix entries are not representable as floats. #1481

@jasongrout

Description

@jasongrout
sage: m=matrix(ZZ,1,[16]); m
[16]
sage: matrix_plot(m^10).show()
---------------------------------------------------------------------------
<type 'exceptions.OverflowError'>         Traceback (most recent call last)

/home/grout/.sage/<ipython console> in <module>()

/home/grout/sage/local/lib/python2.5/site-packages/sage/plot/plot.py in show(self, xmin, xmax, ymin, ymax, figsize, filename, dpi, axes, axes_label, frame, fontsize, **args)
    654         if filename is None:
    655             filename = sage.misc.misc.tmp_filename() + '.png'
--> 656         self.save(filename, xmin, xmax, ymin, ymax, figsize, dpi=dpi, axes=axes,frame=frame, fontsize=fontsize)
    657         os.system('%s %s 2>/dev/null 1>/dev/null &'%(sage.misc.viewer.browser(), filename))
    658

/home/grout/sage/local/lib/python2.5/site-packages/sage/plot/plot.py in save(self, filename, xmin, xmax, ymin, ymax, figsize, figure, sub, savenow, dpi, axes, axes_label, fontsize, frame, verify)
    766             if isinstance(g, GraphicPrimitive_MatrixPlot):
    767                 matrixplot = True
--> 768             g._render_on_subplot(subplot)
    769
    770         #adjust the xy limits and draw the axes:

/home/grout/sage/local/lib/python2.5/site-packages/sage/plot/plot.py in _render_on_subplot(self, subplot)
   1102             print "The possible color maps include: %s"%possibilities
   1103             raise RuntimeError, "Color map %s not known"%cmap
-> 1104         subplot.imshow(self.xy_data_array, cmap=cmap, interpolation='nearest')
   1105
   1106 # Below is the base class that is used to make 'field plots'.

/home/grout/sage/local/lib/python2.5/site-packages/matplotlib/axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, **kwargs)
   4053                        filterrad=filterrad, **kwargs)
   4054
-> 4055         im.set_data(X)
   4056         im.set_alpha(alpha)
   4057         self._set_artist_props(im)

/home/grout/sage/local/lib/python2.5/site-packages/matplotlib/image.py in set_data(self, A, shape)
    224             or X.shape[2] > 4
    225             or X.shape[2] < 3):
--> 226             cm.ScalarMappable.set_array(self, X)
    227         else:
    228             self._A = X

/home/grout/sage/local/lib/python2.5/site-packages/matplotlib/cm.py in set_array(self, A)
     65             self._A = A.astype(nx.Float32)
     66         else:
---> 67             self._A = A.astype(nx.Int16)
     68
     69     def get_array(self):

/home/grout/sage/local/lib/python2.5/site-packages/numpy/core/ma.py in astype(self, tc)
   1148     def astype (self, tc):
   1149         "return self as array of given type."
-> 1150         d = self._data.astype(tc)
   1151         return array(d, mask=self._mask)
   1152

<type 'exceptions.OverflowError'>: long int too large to convert to int

CC: @kcrisman

Component: graphics

Author: William Stein

Reviewer: Karl-Dieter Crisman

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions