Chapter 2: Operators and Fixed Points#
lake.py#
Show code cell source
import numpy as np
α, λ, d, b = 0.01, 0.1, 0.02, 0.025
g = b - d
A = np.mat(np.array([[(1 - d) * (1 - λ) + b, (1 - d) * α + b],
[(1 - d) * λ, (1 - d) * (1 - α)]]))
ū = (1 + g - (1 - d) * (1 - α)) / (1 + g - (1 - d) * (1 - α) + (1 - d) * λ)
ē = 1 - ū
x̄ = np.array([[ū], [ē]])
print(np.allclose(A * x̄, (1 + g) * x̄)) # prints true
# == Plots == #
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
plt.rcParams.update({"text.usetex": True, "font.size": 14})
def plot_paths(figname="figures/lake_1.pdf", savefig=False):
path_length = 100
x_path_1 = np.zeros((2, path_length))
x_path_2 = np.zeros((2, path_length))
x_0_1 = 5.0, 0.1
x_0_2 = 0.1, 4.0
x_path_1[0, 0] = x_0_1[0]
x_path_1[1, 0] = x_0_1[1]
x_path_2[0, 0] = x_0_2[0]
x_path_2[1, 0] = x_0_2[1]
for t in range(path_length-1):
x_path_1[:, t+1] = (A * x_path_1[:, t][np.newaxis].T).flatten()
x_path_2[:, t+1] = (A * x_path_2[:, t][np.newaxis].T).flatten()
fig, ax = plt.subplots()
# Set the axes through the origin
for spine in ["left", "bottom"]:
ax.spines[spine].set_position("zero")
for spine in ["right", "top"]:
ax.spines[spine].set_color("none")
ax.set_xlim(0, 6)
ax.set_ylim(0, 6)
ax.set_xlabel("unemployed workforce")
ax.set_ylabel("employed workforce")
ax.set_xticks((0, 6))
ax.set_yticks((0, 6))
s = 10
ax.plot([0, s * ū], [0, s * ē], "k--", lw=1)
ax.scatter(x_path_1[0, :], x_path_1[1, :], s=4, c="blue")
ax.scatter(x_path_2[0, :], x_path_2[1, :], s=4, c="green")
ax.plot([ū], [ē], "ko", ms=4, alpha=0.6)
ax.annotate(r"$\bar{x}$",
xy=(ū, ē),
xycoords="data",
xytext=(20, -20),
textcoords="offset points",
arrowprops={"arrowstyle" : "->"})
x, y = x_0_1[0], x_0_1[1]
#lb = r"\$x_0 = ($(x), $(y))\$"
ax.plot([x], [y], "ko", ms=2, alpha=0.6)
ax.annotate(rf"$x_0 = ({x}, {y})$",
xy=(x, y),
xycoords="data",
xytext=(0, 20),
textcoords="offset points",
arrowprops={"arrowstyle" : "->"})
x, y = x_0_2[0], x_0_2[1]
#lb = r"\$x_0 = ($(x), $(y))\$"
ax.plot([x], [y], "ko", ms=2, alpha=0.6)
ax.annotate(rf"$x_0 = ({x}, {y})$",
xy=(x, y),
xycoords="data",
xytext=(0, 20),
textcoords="offset points",
arrowprops={"arrowstyle" : "->"})
if savefig:
fig.savefig(figname)
def plot_growth(savefig=False, figname="figures/lake_2.pdf"):
path_length = 100
x_0 = 2.1, 1.2
x = np.zeros((2, path_length))
x[0, 0] = 0.6
x[1, 0] = 1.2
for t in range(path_length-1):
x[:, t+1] = (A * x[:, t][np.newaxis].T).flatten()
fig, axes = plt.subplots(3, 1)
u = x[0, :]
e = x[1, :]
n = x[0, :] + x[1, :]
paths = u, e, n
labels = r"$u_t$", r"$e_t$", r"$n_t$"
for (ax, path, label) in zip(axes, paths, labels):
ax.plot(path, label=label)
ax.legend(frameon=False, fontsize=14)
ax.set_xlabel(r"t")
plt.tight_layout()
if savefig:
fig.savefig(figname)
True
plot_paths()
Error in callback <function _draw_all_if_interactive at 0x7fe0f9e7dcf0> (for post_execute):
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:255, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 try:
--> 255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:421, in check_output(timeout, *popenargs, **kwargs)
419 kwargs['input'] = empty
--> 421 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
422 **kwargs).stdout
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:971, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
-> 1863 raise child_exception_type(errno_num, err_msg, err_filename)
1864 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/pyplot.py:120, in _draw_all_if_interactive()
118 def _draw_all_if_interactive():
119 if matplotlib.is_interactive():
--> 120 draw_all()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:2082, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
2080 if not self._is_idle_drawing:
2081 with self._idle_draw_cntx():
-> 2082 self.draw(*args, **kwargs)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:400, in FigureCanvasAgg.draw(self)
396 # Acquire a lock on the shared font cache.
397 with RendererAgg.lock, \
398 (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
399 else nullcontext()):
--> 400 self.figure.draw(self.renderer)
401 # A GUI class may be need to update a window using this draw, so
402 # don't forget to call the superclass.
403 super().draw()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/figure.py:3140, in Figure.draw(self, renderer)
3137 # ValueError can occur when resizing a window.
3139 self.patch.draw(renderer)
-> 3140 mimage._draw_list_compositing_images(
3141 renderer, self, artists, self.suppressComposite)
3143 for sfig in self.subfigs:
3144 sfig.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axes/_base.py:3064, in _AxesBase.draw(self, renderer)
3061 if artists_rasterized:
3062 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3064 mimage._draw_list_compositing_images(
3065 renderer, self, artists, self.figure.suppressComposite)
3067 renderer.close_group('axes')
3068 self.stale = False
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1377, in Axis.draw(self, renderer, *args, **kwargs)
1374 renderer.open_group(__name__, gid=self.get_gid())
1376 ticks_to_draw = self._update_ticks()
-> 1377 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1379 for tick in ticks_to_draw:
1380 tick.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in <listcomp>(.0)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:959, in Text.get_window_extent(self, renderer, dpi)
954 raise RuntimeError(
955 "Cannot get window extent of text w/o renderer. You likely "
956 "want to call 'figure.draw_without_rendering()' first.")
958 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 959 bbox, info, descent = self._get_layout(self._renderer)
960 x, y = self.get_unitless_position()
961 x, y = self.get_transform().transform((x, y))
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:378, in Text._get_layout(self, renderer)
375 ys = []
377 # Full vertical extent of font, including ascenders and descenders:
--> 378 _, lp_h, lp_d = _get_text_metrics_with_cache(
379 renderer, "lp", self._fontproperties,
380 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
381 min_dy = (lp_h - lp_d) * self._linespacing
383 for i, line in enumerate(lines):
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:97, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
94 """Call ``renderer.get_text_width_height_descent``, caching the results."""
95 # Cached based on a copy of fontprop so that later in-place mutations of
96 # the passed-in argument do not mess up the cache.
---> 97 return _get_text_metrics_with_cache_impl(
98 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:105, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
101 @functools.lru_cache(4096)
102 def _get_text_metrics_with_cache_impl(
103 renderer_ref, text, fontprop, ismath, dpi):
104 # dpi is unused, but participates in cache invalidation (via the renderer).
--> 105 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:226, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
224 _api.check_in_list(["TeX", True, False], ismath=ismath)
225 if ismath == "TeX":
--> 226 return super().get_text_width_height_descent(s, prop, ismath)
228 if ismath:
229 ox, oy, width, height, descent, font_image = \
230 self.mathtext_parser.parse(s, self.dpi, prop)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:645, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
641 fontsize = prop.get_size_in_points()
643 if ismath == 'TeX':
644 # todo: handle properties
--> 645 return self.get_texmanager().get_text_width_height_descent(
646 s, fontsize, renderer=self)
648 dpi = self.points_to_pixels(72)
649 if ismath:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:368, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
366 if tex.strip() == '':
367 return 0, 0, 0
--> 368 dvifile = cls.make_dvi(tex, fontsize)
369 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
370 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:300, in TexManager.make_dvi(cls, tex, fontsize)
298 with TemporaryDirectory(dir=cwd) as tmpdir:
299 tmppath = Path(tmpdir)
--> 300 cls._run_checked_subprocess(
301 ["latex", "-interaction=nonstopmode", "--halt-on-error",
302 f"--output-directory={tmppath.name}",
303 f"{texfile.name}"], tex, cwd=cwd)
304 (tmppath / Path(dvifile).name).replace(dvifile)
305 return dvifile
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:259, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
--> 259 raise RuntimeError(
260 'Failed to process string with tex because {} could not be '
261 'found'.format(command[0])) from exc
262 except subprocess.CalledProcessError as exc:
263 raise RuntimeError(
264 '{prog} was not able to process the following string:\n'
265 '{tex!r}\n\n'
(...)
272 exc=exc.output.decode('utf-8', 'backslashreplace'))
273 ) from None
RuntimeError: Failed to process string with tex because latex could not be found
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:255, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 try:
--> 255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:421, in check_output(timeout, *popenargs, **kwargs)
419 kwargs['input'] = empty
--> 421 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
422 **kwargs).stdout
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:971, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
-> 1863 raise child_exception_type(errno_num, err_msg, err_filename)
1864 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/IPython/core/formatters.py:340, in BaseFormatter.__call__(self, obj)
338 pass
339 else:
--> 340 return printer(obj)
341 # Finally look for special method names
342 method = get_real_method(obj, self.print_method)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:2342, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2336 renderer = _get_renderer(
2337 self.figure,
2338 functools.partial(
2339 print_method, orientation=orientation)
2340 )
2341 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2342 self.figure.draw(renderer)
2344 if bbox_inches:
2345 if bbox_inches == "tight":
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/figure.py:3140, in Figure.draw(self, renderer)
3137 # ValueError can occur when resizing a window.
3139 self.patch.draw(renderer)
-> 3140 mimage._draw_list_compositing_images(
3141 renderer, self, artists, self.suppressComposite)
3143 for sfig in self.subfigs:
3144 sfig.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axes/_base.py:3064, in _AxesBase.draw(self, renderer)
3061 if artists_rasterized:
3062 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3064 mimage._draw_list_compositing_images(
3065 renderer, self, artists, self.figure.suppressComposite)
3067 renderer.close_group('axes')
3068 self.stale = False
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1377, in Axis.draw(self, renderer, *args, **kwargs)
1374 renderer.open_group(__name__, gid=self.get_gid())
1376 ticks_to_draw = self._update_ticks()
-> 1377 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1379 for tick in ticks_to_draw:
1380 tick.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in <listcomp>(.0)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:959, in Text.get_window_extent(self, renderer, dpi)
954 raise RuntimeError(
955 "Cannot get window extent of text w/o renderer. You likely "
956 "want to call 'figure.draw_without_rendering()' first.")
958 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 959 bbox, info, descent = self._get_layout(self._renderer)
960 x, y = self.get_unitless_position()
961 x, y = self.get_transform().transform((x, y))
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:378, in Text._get_layout(self, renderer)
375 ys = []
377 # Full vertical extent of font, including ascenders and descenders:
--> 378 _, lp_h, lp_d = _get_text_metrics_with_cache(
379 renderer, "lp", self._fontproperties,
380 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
381 min_dy = (lp_h - lp_d) * self._linespacing
383 for i, line in enumerate(lines):
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:97, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
94 """Call ``renderer.get_text_width_height_descent``, caching the results."""
95 # Cached based on a copy of fontprop so that later in-place mutations of
96 # the passed-in argument do not mess up the cache.
---> 97 return _get_text_metrics_with_cache_impl(
98 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:105, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
101 @functools.lru_cache(4096)
102 def _get_text_metrics_with_cache_impl(
103 renderer_ref, text, fontprop, ismath, dpi):
104 # dpi is unused, but participates in cache invalidation (via the renderer).
--> 105 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:226, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
224 _api.check_in_list(["TeX", True, False], ismath=ismath)
225 if ismath == "TeX":
--> 226 return super().get_text_width_height_descent(s, prop, ismath)
228 if ismath:
229 ox, oy, width, height, descent, font_image = \
230 self.mathtext_parser.parse(s, self.dpi, prop)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:645, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
641 fontsize = prop.get_size_in_points()
643 if ismath == 'TeX':
644 # todo: handle properties
--> 645 return self.get_texmanager().get_text_width_height_descent(
646 s, fontsize, renderer=self)
648 dpi = self.points_to_pixels(72)
649 if ismath:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:368, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
366 if tex.strip() == '':
367 return 0, 0, 0
--> 368 dvifile = cls.make_dvi(tex, fontsize)
369 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
370 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:300, in TexManager.make_dvi(cls, tex, fontsize)
298 with TemporaryDirectory(dir=cwd) as tmpdir:
299 tmppath = Path(tmpdir)
--> 300 cls._run_checked_subprocess(
301 ["latex", "-interaction=nonstopmode", "--halt-on-error",
302 f"--output-directory={tmppath.name}",
303 f"{texfile.name}"], tex, cwd=cwd)
304 (tmppath / Path(dvifile).name).replace(dvifile)
305 return dvifile
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:259, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
--> 259 raise RuntimeError(
260 'Failed to process string with tex because {} could not be '
261 'found'.format(command[0])) from exc
262 except subprocess.CalledProcessError as exc:
263 raise RuntimeError(
264 '{prog} was not able to process the following string:\n'
265 '{tex!r}\n\n'
(...)
272 exc=exc.output.decode('utf-8', 'backslashreplace'))
273 ) from None
RuntimeError: Failed to process string with tex because latex could not be found
<Figure size 640x480 with 1 Axes>
plot_growth()
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:255, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 try:
--> 255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:421, in check_output(timeout, *popenargs, **kwargs)
419 kwargs['input'] = empty
--> 421 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
422 **kwargs).stdout
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:971, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
-> 1863 raise child_exception_type(errno_num, err_msg, err_filename)
1864 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 plot_growth()
Cell In[1], line 115, in plot_growth(savefig, figname)
112 ax.legend(frameon=False, fontsize=14)
113 ax.set_xlabel(r"t")
--> 115 plt.tight_layout()
116 if savefig:
117 fig.savefig(figname)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/pyplot.py:2349, in tight_layout(pad, h_pad, w_pad, rect)
2347 @_copy_docstring_and_deprecators(Figure.tight_layout)
2348 def tight_layout(*, pad=1.08, h_pad=None, w_pad=None, rect=None):
-> 2349 return gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/figure.py:3509, in Figure.tight_layout(self, pad, h_pad, w_pad, rect)
3507 previous_engine = self.get_layout_engine()
3508 self.set_layout_engine(engine)
-> 3509 engine.execute(self)
3510 if not isinstance(previous_engine, TightLayoutEngine) \
3511 and previous_engine is not None:
3512 _api.warn_external('The figure layout has changed to tight')
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/layout_engine.py:178, in TightLayoutEngine.execute(self, fig)
176 renderer = fig._get_renderer()
177 with getattr(renderer, "_draw_disabled", nullcontext)():
--> 178 kwargs = get_tight_layout_figure(
179 fig, fig.axes, get_subplotspec_list(fig.axes), renderer,
180 pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'],
181 rect=info['rect'])
182 if kwargs:
183 fig.subplots_adjust(**kwargs)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/_tight_layout.py:266, in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
261 return {}
262 span_pairs.append((
263 slice(ss.rowspan.start * div_row, ss.rowspan.stop * div_row),
264 slice(ss.colspan.start * div_col, ss.colspan.stop * div_col)))
--> 266 kwargs = _auto_adjust_subplotpars(fig, renderer,
267 shape=(max_nrows, max_ncols),
268 span_pairs=span_pairs,
269 subplot_list=subplot_list,
270 ax_bbox_list=ax_bbox_list,
271 pad=pad, h_pad=h_pad, w_pad=w_pad)
273 # kwargs can be none if tight_layout fails...
274 if rect is not None and kwargs is not None:
275 # if rect is given, the whole subplots area (including
276 # labels) will fit into the rect instead of the
(...)
280 # auto_adjust_subplotpars twice, where the second run
281 # with adjusted rect parameters.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/_tight_layout.py:82, in _auto_adjust_subplotpars(fig, renderer, shape, span_pairs, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
80 for ax in subplots:
81 if ax.get_visible():
---> 82 bb += [martist._get_tightbbox_for_layout_only(ax, renderer)]
84 tight_bbox_raw = Bbox.union(bb)
85 tight_bbox = fig.transFigure.inverted().transform_bbox(tight_bbox_raw)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:1415, in _get_tightbbox_for_layout_only(obj, *args, **kwargs)
1409 """
1410 Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
1411 *for_layout_only* kwarg; this helper tries to use the kwarg but skips it
1412 when encountering third-party subclasses that do not support it.
1413 """
1414 try:
-> 1415 return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
1416 except TypeError:
1417 return obj.get_tightbbox(*args, **kwargs)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axes/_base.py:4385, in _AxesBase.get_tightbbox(self, renderer, call_axes_locator, bbox_extra_artists, for_layout_only)
4383 for axis in self._axis_map.values():
4384 if self.axison and axis.get_visible():
-> 4385 ba = martist._get_tightbbox_for_layout_only(axis, renderer)
4386 if ba:
4387 bb.append(ba)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:1415, in _get_tightbbox_for_layout_only(obj, *args, **kwargs)
1409 """
1410 Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
1411 *for_layout_only* kwarg; this helper tries to use the kwarg but skips it
1412 when encountering third-party subclasses that do not support it.
1413 """
1414 try:
-> 1415 return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
1416 except TypeError:
1417 return obj.get_tightbbox(*args, **kwargs)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1325, in Axis.get_tightbbox(self, renderer, for_layout_only)
1322 renderer = self.figure._get_renderer()
1323 ticks_to_draw = self._update_ticks()
-> 1325 self._update_label_position(renderer)
1327 # go back to just this axis's tick labels
1328 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:2304, in XAxis._update_label_position(self, renderer)
2300 return
2302 # get bounding boxes for this axis and any siblings
2303 # that have been set by `fig.align_xlabels()`
-> 2304 bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
2306 x, y = self.label.get_position()
2307 if self.label_position == 'bottom':
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:2100, in Axis._get_tick_boxes_siblings(self, renderer)
2098 axis = getattr(ax, f"{axis_name}axis")
2099 ticks_to_draw = axis._update_ticks()
-> 2100 tlb, tlb2 = axis._get_ticklabel_bboxes(ticks_to_draw, renderer)
2101 bboxes.extend(tlb)
2102 bboxes2.extend(tlb2)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in <listcomp>(.0)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:959, in Text.get_window_extent(self, renderer, dpi)
954 raise RuntimeError(
955 "Cannot get window extent of text w/o renderer. You likely "
956 "want to call 'figure.draw_without_rendering()' first.")
958 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 959 bbox, info, descent = self._get_layout(self._renderer)
960 x, y = self.get_unitless_position()
961 x, y = self.get_transform().transform((x, y))
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:378, in Text._get_layout(self, renderer)
375 ys = []
377 # Full vertical extent of font, including ascenders and descenders:
--> 378 _, lp_h, lp_d = _get_text_metrics_with_cache(
379 renderer, "lp", self._fontproperties,
380 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
381 min_dy = (lp_h - lp_d) * self._linespacing
383 for i, line in enumerate(lines):
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:97, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
94 """Call ``renderer.get_text_width_height_descent``, caching the results."""
95 # Cached based on a copy of fontprop so that later in-place mutations of
96 # the passed-in argument do not mess up the cache.
---> 97 return _get_text_metrics_with_cache_impl(
98 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:105, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
101 @functools.lru_cache(4096)
102 def _get_text_metrics_with_cache_impl(
103 renderer_ref, text, fontprop, ismath, dpi):
104 # dpi is unused, but participates in cache invalidation (via the renderer).
--> 105 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:226, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
224 _api.check_in_list(["TeX", True, False], ismath=ismath)
225 if ismath == "TeX":
--> 226 return super().get_text_width_height_descent(s, prop, ismath)
228 if ismath:
229 ox, oy, width, height, descent, font_image = \
230 self.mathtext_parser.parse(s, self.dpi, prop)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:645, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
641 fontsize = prop.get_size_in_points()
643 if ismath == 'TeX':
644 # todo: handle properties
--> 645 return self.get_texmanager().get_text_width_height_descent(
646 s, fontsize, renderer=self)
648 dpi = self.points_to_pixels(72)
649 if ismath:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:368, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
366 if tex.strip() == '':
367 return 0, 0, 0
--> 368 dvifile = cls.make_dvi(tex, fontsize)
369 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
370 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:300, in TexManager.make_dvi(cls, tex, fontsize)
298 with TemporaryDirectory(dir=cwd) as tmpdir:
299 tmppath = Path(tmpdir)
--> 300 cls._run_checked_subprocess(
301 ["latex", "-interaction=nonstopmode", "--halt-on-error",
302 f"--output-directory={tmppath.name}",
303 f"{texfile.name}"], tex, cwd=cwd)
304 (tmppath / Path(dvifile).name).replace(dvifile)
305 return dvifile
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:259, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
--> 259 raise RuntimeError(
260 'Failed to process string with tex because {} could not be '
261 'found'.format(command[0])) from exc
262 except subprocess.CalledProcessError as exc:
263 raise RuntimeError(
264 '{prog} was not able to process the following string:\n'
265 '{tex!r}\n\n'
(...)
272 exc=exc.output.decode('utf-8', 'backslashreplace'))
273 ) from None
RuntimeError: Failed to process string with tex because latex could not be found
Error in callback <function _draw_all_if_interactive at 0x7fe0f9e7dcf0> (for post_execute):
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:255, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 try:
--> 255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:421, in check_output(timeout, *popenargs, **kwargs)
419 kwargs['input'] = empty
--> 421 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
422 **kwargs).stdout
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:971, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
-> 1863 raise child_exception_type(errno_num, err_msg, err_filename)
1864 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/pyplot.py:120, in _draw_all_if_interactive()
118 def _draw_all_if_interactive():
119 if matplotlib.is_interactive():
--> 120 draw_all()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:2082, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
2080 if not self._is_idle_drawing:
2081 with self._idle_draw_cntx():
-> 2082 self.draw(*args, **kwargs)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:400, in FigureCanvasAgg.draw(self)
396 # Acquire a lock on the shared font cache.
397 with RendererAgg.lock, \
398 (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
399 else nullcontext()):
--> 400 self.figure.draw(self.renderer)
401 # A GUI class may be need to update a window using this draw, so
402 # don't forget to call the superclass.
403 super().draw()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/figure.py:3140, in Figure.draw(self, renderer)
3137 # ValueError can occur when resizing a window.
3139 self.patch.draw(renderer)
-> 3140 mimage._draw_list_compositing_images(
3141 renderer, self, artists, self.suppressComposite)
3143 for sfig in self.subfigs:
3144 sfig.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axes/_base.py:3064, in _AxesBase.draw(self, renderer)
3061 if artists_rasterized:
3062 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3064 mimage._draw_list_compositing_images(
3065 renderer, self, artists, self.figure.suppressComposite)
3067 renderer.close_group('axes')
3068 self.stale = False
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1377, in Axis.draw(self, renderer, *args, **kwargs)
1374 renderer.open_group(__name__, gid=self.get_gid())
1376 ticks_to_draw = self._update_ticks()
-> 1377 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1379 for tick in ticks_to_draw:
1380 tick.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in <listcomp>(.0)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:959, in Text.get_window_extent(self, renderer, dpi)
954 raise RuntimeError(
955 "Cannot get window extent of text w/o renderer. You likely "
956 "want to call 'figure.draw_without_rendering()' first.")
958 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 959 bbox, info, descent = self._get_layout(self._renderer)
960 x, y = self.get_unitless_position()
961 x, y = self.get_transform().transform((x, y))
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:378, in Text._get_layout(self, renderer)
375 ys = []
377 # Full vertical extent of font, including ascenders and descenders:
--> 378 _, lp_h, lp_d = _get_text_metrics_with_cache(
379 renderer, "lp", self._fontproperties,
380 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
381 min_dy = (lp_h - lp_d) * self._linespacing
383 for i, line in enumerate(lines):
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:97, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
94 """Call ``renderer.get_text_width_height_descent``, caching the results."""
95 # Cached based on a copy of fontprop so that later in-place mutations of
96 # the passed-in argument do not mess up the cache.
---> 97 return _get_text_metrics_with_cache_impl(
98 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:105, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
101 @functools.lru_cache(4096)
102 def _get_text_metrics_with_cache_impl(
103 renderer_ref, text, fontprop, ismath, dpi):
104 # dpi is unused, but participates in cache invalidation (via the renderer).
--> 105 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:226, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
224 _api.check_in_list(["TeX", True, False], ismath=ismath)
225 if ismath == "TeX":
--> 226 return super().get_text_width_height_descent(s, prop, ismath)
228 if ismath:
229 ox, oy, width, height, descent, font_image = \
230 self.mathtext_parser.parse(s, self.dpi, prop)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:645, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
641 fontsize = prop.get_size_in_points()
643 if ismath == 'TeX':
644 # todo: handle properties
--> 645 return self.get_texmanager().get_text_width_height_descent(
646 s, fontsize, renderer=self)
648 dpi = self.points_to_pixels(72)
649 if ismath:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:368, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
366 if tex.strip() == '':
367 return 0, 0, 0
--> 368 dvifile = cls.make_dvi(tex, fontsize)
369 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
370 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:300, in TexManager.make_dvi(cls, tex, fontsize)
298 with TemporaryDirectory(dir=cwd) as tmpdir:
299 tmppath = Path(tmpdir)
--> 300 cls._run_checked_subprocess(
301 ["latex", "-interaction=nonstopmode", "--halt-on-error",
302 f"--output-directory={tmppath.name}",
303 f"{texfile.name}"], tex, cwd=cwd)
304 (tmppath / Path(dvifile).name).replace(dvifile)
305 return dvifile
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:259, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
--> 259 raise RuntimeError(
260 'Failed to process string with tex because {} could not be '
261 'found'.format(command[0])) from exc
262 except subprocess.CalledProcessError as exc:
263 raise RuntimeError(
264 '{prog} was not able to process the following string:\n'
265 '{tex!r}\n\n'
(...)
272 exc=exc.output.decode('utf-8', 'backslashreplace'))
273 ) from None
RuntimeError: Failed to process string with tex because latex could not be found
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:255, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
254 try:
--> 255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:421, in check_output(timeout, *popenargs, **kwargs)
419 kwargs['input'] = empty
--> 421 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
422 **kwargs).stdout
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:971, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
-> 1863 raise child_exception_type(errno_num, err_msg, err_filename)
1864 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'latex'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/IPython/core/formatters.py:340, in BaseFormatter.__call__(self, obj)
338 pass
339 else:
--> 340 return printer(obj)
341 # Finally look for special method names
342 method = get_real_method(obj, self.print_method)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:2342, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2336 renderer = _get_renderer(
2337 self.figure,
2338 functools.partial(
2339 print_method, orientation=orientation)
2340 )
2341 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2342 self.figure.draw(renderer)
2344 if bbox_inches:
2345 if bbox_inches == "tight":
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/figure.py:3140, in Figure.draw(self, renderer)
3137 # ValueError can occur when resizing a window.
3139 self.patch.draw(renderer)
-> 3140 mimage._draw_list_compositing_images(
3141 renderer, self, artists, self.suppressComposite)
3143 for sfig in self.subfigs:
3144 sfig.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axes/_base.py:3064, in _AxesBase.draw(self, renderer)
3061 if artists_rasterized:
3062 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3064 mimage._draw_list_compositing_images(
3065 renderer, self, artists, self.figure.suppressComposite)
3067 renderer.close_group('axes')
3068 self.stale = False
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
134 image_group = []
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1377, in Axis.draw(self, renderer, *args, **kwargs)
1374 renderer.open_group(__name__, gid=self.get_gid())
1376 ticks_to_draw = self._update_ticks()
-> 1377 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1379 for tick in ticks_to_draw:
1380 tick.draw(renderer)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/axis.py:1304, in <listcomp>(.0)
1302 if renderer is None:
1303 renderer = self.figure._get_renderer()
-> 1304 return ([tick.label1.get_window_extent(renderer)
1305 for tick in ticks if tick.label1.get_visible()],
1306 [tick.label2.get_window_extent(renderer)
1307 for tick in ticks if tick.label2.get_visible()])
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:959, in Text.get_window_extent(self, renderer, dpi)
954 raise RuntimeError(
955 "Cannot get window extent of text w/o renderer. You likely "
956 "want to call 'figure.draw_without_rendering()' first.")
958 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 959 bbox, info, descent = self._get_layout(self._renderer)
960 x, y = self.get_unitless_position()
961 x, y = self.get_transform().transform((x, y))
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:378, in Text._get_layout(self, renderer)
375 ys = []
377 # Full vertical extent of font, including ascenders and descenders:
--> 378 _, lp_h, lp_d = _get_text_metrics_with_cache(
379 renderer, "lp", self._fontproperties,
380 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
381 min_dy = (lp_h - lp_d) * self._linespacing
383 for i, line in enumerate(lines):
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:97, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
94 """Call ``renderer.get_text_width_height_descent``, caching the results."""
95 # Cached based on a copy of fontprop so that later in-place mutations of
96 # the passed-in argument do not mess up the cache.
---> 97 return _get_text_metrics_with_cache_impl(
98 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/text.py:105, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
101 @functools.lru_cache(4096)
102 def _get_text_metrics_with_cache_impl(
103 renderer_ref, text, fontprop, ismath, dpi):
104 # dpi is unused, but participates in cache invalidation (via the renderer).
--> 105 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:226, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
224 _api.check_in_list(["TeX", True, False], ismath=ismath)
225 if ismath == "TeX":
--> 226 return super().get_text_width_height_descent(s, prop, ismath)
228 if ismath:
229 ox, oy, width, height, descent, font_image = \
230 self.mathtext_parser.parse(s, self.dpi, prop)
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/backend_bases.py:645, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
641 fontsize = prop.get_size_in_points()
643 if ismath == 'TeX':
644 # todo: handle properties
--> 645 return self.get_texmanager().get_text_width_height_descent(
646 s, fontsize, renderer=self)
648 dpi = self.points_to_pixels(72)
649 if ismath:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:368, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
366 if tex.strip() == '':
367 return 0, 0, 0
--> 368 dvifile = cls.make_dvi(tex, fontsize)
369 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
370 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:300, in TexManager.make_dvi(cls, tex, fontsize)
298 with TemporaryDirectory(dir=cwd) as tmpdir:
299 tmppath = Path(tmpdir)
--> 300 cls._run_checked_subprocess(
301 ["latex", "-interaction=nonstopmode", "--halt-on-error",
302 f"--output-directory={tmppath.name}",
303 f"{texfile.name}"], tex, cwd=cwd)
304 (tmppath / Path(dvifile).name).replace(dvifile)
305 return dvifile
File /usr/share/miniconda3/envs/dse2023/lib/python3.10/site-packages/matplotlib/texmanager.py:259, in TexManager._run_checked_subprocess(cls, command, tex, cwd)
255 report = subprocess.check_output(
256 command, cwd=cwd if cwd is not None else cls.texcache,
257 stderr=subprocess.STDOUT)
258 except FileNotFoundError as exc:
--> 259 raise RuntimeError(
260 'Failed to process string with tex because {} could not be '
261 'found'.format(command[0])) from exc
262 except subprocess.CalledProcessError as exc:
263 raise RuntimeError(
264 '{prog} was not able to process the following string:\n'
265 '{tex!r}\n\n'
(...)
272 exc=exc.output.decode('utf-8', 'backslashreplace'))
273 ) from None
RuntimeError: Failed to process string with tex because latex could not be found
<Figure size 640x480 with 3 Axes>