【发布时间】:2019-08-21 03:45:52
【问题描述】:
我正在尝试使用 matplotlib 绘制乳胶。 我已经用 pip 安装了乳胶。 这个example 效果很好
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t,s)
plt.title(r'$\alpha_i > \beta_i$', fontsize=20)
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.show()
而matplotlib.rcParams['text.usetex'] = True 遇到乳胶错误。
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t,s)
plt.title(r'$\alpha_i > \beta_i$', fontsize=20)
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.show()
产生这个堆栈
----------------------------------- ---------------------------- FileNotFoundError Traceback(最近调用 最后的) ~/anaconda3/envs/tf11/lib/python3.6/site-packages/IPython/core/formatters.py 在 调用(self, obj) 330通 331 其他: --> 332 返回打印机(obj) 333 # 最后寻找特殊的方法名 334 方法 = get_real_method(obj, self.print_method)
~/anaconda3/envs/tf11/lib/python3.6/site-packages/IPython/core/pylabtools.py 在(图) 235 236 如果格式为“png”: --> 237 png_formatter.for_type(图, lambda fig: print_figure(fig, 'png', **kwargs)) 238 如果格式为“retina”或格式为“png2x”: 第239章
~/anaconda3/envs/tf11/lib/python3.6/site-packages/IPython/core/pylabtools.py 在 print_figure (fig, fmt, bbox_inches, **kwargs) 119 120 bytes_io = BytesIO() --> 121 fig.canvas.print_figure(bytes_io, **kw) 122 数据 = bytes_io.getvalue() 123 如果 fmt == 'svg':
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/backend_bases.py 在 print_figure(self, 文件名, dpi, facecolor, edgecolor, 方向、格式、bbox_inches、**kwargs) 2047
方向=方向,2048 空运行=真, -> 2049 **kwargs) 2050 渲染器 = self.figure._cachedRenderer 2051
bbox_artists = kwargs.pop("bbox_extra_artists", None)~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py 在 print_png(self, filename_or_obj, *args, **kwargs) 508 第509章 --> 510 FigureCanvasAgg.draw(self) 511 渲染器 = self.get_renderer() 第512章
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py 在画中(自己) 400 工具栏 = self.toolbar 401尝试: --> 402 self.figure.draw(self.renderer) 403 # 一个 GUI 类可能需要使用这个绘制来更新一个窗口,所以 404 # 不要忘记调用超类。
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/artist.py 在draw_wrapper(艺术家,渲染器,*args,**kwargs) 48 渲染器.start_filter() 49 ---> 50 返回绘图(艺术家、渲染器、*args、**kwargs) 51最后: 52 如果 Artist.get_agg_filter() 不是无:
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/figure.py 在绘图(自我,渲染器)1650 1651
mimage._draw_list_compositing_images( -> 1652 渲染器,自我,艺术家,self.suppressComposite)1653 1654
renderer.close_group('figure')~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/image.py 在 _draw_list_compositing_images(渲染器,父级,艺术家, 抑制复合) 136 如果 not_composite 或没有 has_images: 137 位艺术家: --> 138 a.draw(渲染器) 139 其他: 140 # 将任何相邻的图像合成在一起
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/artist.py 在draw_wrapper(艺术家,渲染器,*args,**kwargs) 48 渲染器.start_filter() 49 ---> 50 返回绘图(艺术家、渲染器、*args、**kwargs) 51最后: 52 如果 Artist.get_agg_filter() 不是无:
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/axes/_base.py 在绘图(自我,渲染器,内框)2602
渲染器.stop_rasterizing() 2603 -> 2604 mimage._draw_list_compositing_images(renderer, self, Artists) 2605 2606 renderer.close_group('axes')~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/image.py 在 _draw_list_compositing_images(渲染器,父级,艺术家, 抑制复合) 136 如果 not_composite 或没有 has_images: 137 位艺术家: --> 138 a.draw(渲染器) 139 其他: 140 # 将任何相邻的图像合成在一起
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/artist.py 在draw_wrapper(艺术家,渲染器,*args,**kwargs) 48 渲染器.start_filter() 49 ---> 50 返回绘图(艺术家、渲染器、*args、**kwargs) 51最后: 52 如果 Artist.get_agg_filter() 不是无:
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/axis.py 在 draw(self, renderer, *args, **kwargs) 1185 ticks_to_draw = self._update_ticks(渲染器)1186 ticklabelBoxes,ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, -> 1187 渲染器)1188 1189 用于 ticks_to_draw 中的刻度:
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/axis.py 在 _get_tick_bboxes(self, ticks, renderer) 1123 中勾选 滴答声:1124 如果 tick.label1On 和 tick.label1.get_visible(): -> 1125 范围 = tick.label1.get_window_extent(renderer) 1126
ticklabelBoxes.append(extent) 1127 如果 tick.label2On 和 tick.label2.get_visible():~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/text.py 在 get_window_extent(self, renderer, dpi) 927 引发 RuntimeError('无法获得不带渲染器的窗口范围') 928 --> 929 bbox,信息,下降 = self._get_layout(self._renderer) 第930章 931 x, y = self.get_transform().transform_point((x, y))
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/text.py 在 _get_layout(自我,渲染器) 第311章 第312章 --> 313 ismath=ismath) 314 其他: 315 w, h, d = 0, 0, 0
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py 在 get_text_width_height_descent(self, s, prop, ismath) 207 字体大小 = prop.get_size_in_points() 208 w,h,d = texmanager.get_text_width_height_descent( --> 209 s, fontsize, renderer=self) 210 返回 w、h、d 211
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/texmanager.py 在 get_text_width_height_descent(self, tex, fontsize, renderer) 462 其他: 463#使用dviread。它有时会返回错误的下降。 --> 464 dvifile = self.make_dvi(tex, fontsize) 465 与 dviread.Dvi(dvifile, 72 * dpi_fraction) 作为 dvi: 466页=下一个(iter(dvi))
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/texmanager.py 在 make_dvi(self, tex, fontsize) 第326章 第327章 --> 328 texfile], tex) 329 for fname in glob.glob(basefile + '*'): 330 如果不是 fname.endswith(('dvi', 'tex')):
~/anaconda3/envs/tf11/lib/python3.6/site-packages/matplotlib/texmanager.py 在 _run_checked_subprocess(self, command, tex) 第296章 第297章 --> 298 标准错误=子进程.STDOUT) 299 除了 subprocess.CalledProcessError 作为 exc: 300 引发 RuntimeError(
~/anaconda3/envs/tf11/lib/python3.6/subprocess.py 在 check_output(超时,*popenargs,**kwargs) 334 335返回运行(* popenargs,标准输出=管道,超时=超时,检查=真, --> 336 **kwargs).stdout 337 第338章
~/anaconda3/envs/tf11/lib/python3.6/subprocess.py 在运行中(输入, 超时,检查,*popenargs,**kwargs) 401 kwargs ['stdin'] = 管道 402 --> 403 使用 Popen(*popenargs, **kwargs) 作为进程: 404尝试: 405 标准输出,标准错误 = 进程。通信(输入,超时 = 超时)
~/anaconda3/envs/tf11/lib/python3.6/subprocess.py in init(self, 参数,bufsize,可执行文件,标准输入,标准输出,标准错误,preexec_fn, close_fds、shell、cwd、env、universal_newlines、startupinfo、 creationflags,restore_signals,start_new_session,pass_fds,编码, 错误) 第705章 第706章 --> 707 恢复信号,开始新会话) 708 除了: 709 # 如果子进程启动失败则清理。
~/anaconda3/envs/tf11/lib/python3.6/subprocess.py 在 _execute_child(self, args, 可执行文件, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite、c2pread、c2pwrite、errread、errwrite、restore_signals、 start_new_session) 1331 其他:1332
err_msg += ': ' + repr(orig_executable) -> 1333 提高 child_exception_type(errno_num,err_msg)1334 提高 child_exception_type(err_msg)
第1335章FileNotFoundError: [Errno 2] 没有这样的文件或目录:'latex'
【问题讨论】:
标签: python matplotlib latex