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

[pylab inline backend] pylab.text() fails for large coordinates #1740

Closed
jordens opened this issue May 15, 2012 · 5 comments
Closed

[pylab inline backend] pylab.text() fails for large coordinates #1740

jordens opened this issue May 15, 2012 · 5 comments
Milestone

Comments

@jordens
Copy link

jordens commented May 15, 2012

pyplot.text() makes the inline backend of ipython-notebook choke. For smaller coordinates (e.g. 1e1) it works fine.

In [31]:

from matplotlib import pyplot as plt
plt.text(1e2, 0, "foo")
Out[31]:
<matplotlib.text.Text at 0x523e810>
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/zmq/pylab/backend_inline.pyc in show(close)
    100     try:
    101         for figure_manager in Gcf.get_all_fig_managers():
--> 102             send_figure(figure_manager.canvas.figure)
    103     finally:
    104         show._to_draw = []

/usr/lib/python2.7/dist-packages/IPython/zmq/pylab/backend_inline.pyc in send_figure(fig)
    209     """
    210     fmt = InlineBackend.instance().figure_format
--> 211     data = print_figure(fig, fmt)
    212     # print_figure will return None if there's nothing to draw:
    213     if data is None:

/usr/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt)
    102     try:
    103         bytes_io = BytesIO()
--> 104         fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight')
    105         data = bytes_io.getvalue()
    106     finally:

/usr/lib/pymodules/python2.7/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2019                 orientation=orientation,
   2020                 bbox_inches_restore=_bbox_inches_restore,
-> 2021                 **kwargs)
   2022         finally:
   2023             if bbox_inches and restore_bbox:

/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    467 
    468     def print_png(self, filename_or_obj, *args, **kwargs):
--> 469         FigureCanvasAgg.draw(self)
    470         renderer = self.get_renderer()
    471         original_dpi = renderer.dpi

/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc in draw(self)
    414         if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
    415 
--> 416         self.renderer = self.get_renderer()
    417         # acquire a lock on the shared font cache
    418         RendererAgg.lock.acquire()

/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc in get_renderer(self)
    433 
    434         if need_new_renderer:
--> 435             self.renderer = RendererAgg(w, h, self.figure.dpi)
    436             self._lastKey = key
    437         return self.renderer

/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.pyc in __init__(self, width, height, dpi)
     70         self.height = height
     71         if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
---> 72         self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
     73         self._filter_renderers = []
     74 

ValueError: width and height must each be below 32768
@jordens
Copy link
Author

jordens commented May 15, 2012

this is git commit 83e0ea6
via the packages from https://code.launchpad.net/~jtaylor/+recipe/ipython-daily

@minrk
Copy link
Member

minrk commented May 15, 2012

This should probably be brought up with @matplotlib, which is where this exists (as indicated by the traceback above).

@jordens
Copy link
Author

jordens commented May 15, 2012

That depends on who determines the width and height arguments. The testcase works fine in Ipython on the text console and in a script.

@jordens
Copy link
Author

jordens commented May 21, 2012

This is due to the use of bbox_inches="tight" resizing the figure according to all text artists. I have filed matplotlib/matplotlib#883. But there might be two bugs: It appears wrong that bbox_inches="tight" resizes according to all text artists. Also ipython might just accept the size of the figure as it was specified in figsize and ask for the bounding box to be used as the size. Clipping text in the title etc is a result of the spacings not being correct. The figure should be as large as specified in figsize.

@ivanov
Copy link
Member

ivanov commented Jun 17, 2014

This bug has two years of inactivity - I am not seeing the originally reported traceback behavior in IPython master and matplotlib's 883 was closed as "wontfix" so I'm going to go ahead and close this one as well.

@ivanov ivanov closed this as completed Jun 17, 2014
@ivanov ivanov added this to the no action milestone Jun 17, 2014
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