Closed
Description
Bug report
Bug summary
If I run the Textbox example script (https://matplotlib.org/gallery/widgets/textbox.html) with v2.1.0 (or the current master or v2.1.x branch), the plotting window opens ok. When I click on the Textbox widget, a RuntimeError is raised. (Cannot get window extent w/o renderer
)
(Apologies if this has been reported before, I couldn't find anything when searching for it)
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import TextBox
fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.2)
t = np.arange(-2.0, 2.0, 0.001)
s = t ** 2
initial_text = "t ** 2"
l, = plt.plot(t, s, lw=2)
def submit(text):
ydata = eval(text)
l.set_ydata(ydata)
ax.set_ylim(np.min(ydata), np.max(ydata))
plt.draw()
axbox = plt.axes([0.1, 0.05, 0.8, 0.075])
text_box = TextBox(axbox, 'Evaluate', initial=initial_text)
text_box.on_submit(submit)
plt.show()
Actual outcome
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/cbook/__init__.py", line 389, in process
proxy(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/cbook/__init__.py", line 227, in __call__
return mtd(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 865, in _click
self.position_cursor(event.x)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 851, in position_cursor
self._rendercursor()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 726, in _rendercursor
bb = wt_disp.get_window_extent()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/text.py", line 971, in get_window_extent
raise RuntimeError('Cannot get window extent w/o renderer')
RuntimeError: Cannot get window extent w/o renderer
Expected outcome
The textbox should become active and allow me to edit the text
Matplotlib version
- Operating system: MacOS 10.12.6 (16G29)
- Matplotlib version: 2.1.0 (also tried with master and v2.1.x branch)
- Matplotlib backend (print(matplotlib.get_backend())): MacOSX
- Python version: Python 2.7.14 (default, Sep 22 2017, 00:06:07)
python installed from MacPorts
matplotlib v2.1.0 installed from Macports
Also tried matplotlib master and v2.1.x branch installed from source (python setup.py install
)