Я пытаюсь построить графики плотности из некоторых данных, используя seaborn.
Он работает нормально без латекса, но когда я пытаюсь построить график с латексом, он выдает ошибку.
Вот настройки:
rcParams['text.usetex'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)
plt.rcParams.update()
sns.set_context("paper")
sns.set(font_scale=1.5, rc={'text.usetex' : True})
sns.set_style('white', {'font.family':'serif', 'font.serif':'Times New Roman', 'background':'white'})
sns.despine()
и график строится с помощью:
sns.kdeplot(np.array(data), bw=0.4, cut=0)
plt.tight_layout(True)
plt.savefig('file.png', dpi=300)
Вот ошибка:
File "plotGraphs.py", line 214, in <module>
plotCarsReached()
File "plotGraphs.py", line 118, in plotCarsReached
plt.tight_layout(True)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/pyplot.py", line 1337, in tight_layout
gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 358, in wrapper
return func(*args, **kwargs)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/figure.py", line 2491, in tight_layout
kwargs = get_tight_layout_figure(
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/tight_layout.py", line 355, in get_tight_layout_figure
kwargs = auto_adjust_subplotpars(fig, renderer,
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/tight_layout.py", line 109, in auto_adjust_subplotpars
tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/tight_layout.py", line 109, in <listcomp>
tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 4317, in get_tightbbox
bb_xaxis = self.xaxis.get_tightbbox(renderer)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/axis.py", line 1197, in get_tightbbox
bboxes = [
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/axis.py", line 1198, in <genexpr>
*(a.get_window_extent(renderer)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/text.py", line 905, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/text.py", line 299, in _get_layout
w, h, d = renderer.get_text_width_height_descent(
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 203, in get_text_width_height_descent
w, h, d = texmanager.get_text_width_height_descent(
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/texmanager.py", line 451, in get_text_width_height_descent
with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
File "/Users/iMac/.pyenv/versions/3.8.0/lib/python3.8/site-packages/matplotlib/dviread.py", line 198, in __init__
self.file = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/iMac/.matplotlib/tex.cache/bff659c457d4aecfc8f90b11c18fa8b1.dvi'
Если я удаляю начальные настройки, сюжет работает. Другие сюжеты, использующие matplotlib вместо seaborn, также работают.
Кто-нибудь знает, как это исправить?