You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a linux system which I do not have root privileges to. As such, I have created a virtual environment so I can use modules as I need without installing them fully on the system.
I experienced an error when trying to use Latex as a text renderer for plots I am making for publication in my virtual environment.
I do not get an error and everything works fine when I run the same code snippet outside of my virtual environment and I need to work in my virtual environment as there are certain modules I need to compute other parts the code.
I am aware a similar issue was raised here the resolution appears to be reinstall/update whatever Tex distribution I have but I can not do that as I do not have root privileges on my system. So is there a work around I could use in my vitual environment?
Thanks in advance.
Code for reproduction
importmatplotlibasmplmpl.use('Agg') # Use this backend for writing plots to fileimportmatplotlib.pyplotaspltplt.style.use('seaborn-talk')
mpl.rcParams['figure.figsize'] = [10, 8]
mpl.rcParams['figure.autolayout'] =Truempl.rcParams['text.usetex'] =True# <------- This seems to be issuempl.rcParams['font.family'] ='serif'mpl.rcParams['font.serif'] ='Computer Modern Roman'mpl.rcParams['lines.linewidth'] =1.25mpl.rcParams['lines.markersize'] =6# Simple Plot of Dataplt.plot(np.arange(10), np.sin(np.arange(10)))
plt.xlim(0, 2*np.pi)
plt.ylim(-3.2, 3.2)
plt.xlabel(r'$x$')
plt.ylabel(r'$u(x, t) / u_{rms}(x, t)$')
plt.show()
Actual outcome
Traceback (most recent call last):
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 306, in _run_checked_subprocess
stderr=subprocess.STDOUT)
File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '/home/ecarroll/.cache/matplotlib/tex.cache/f0d1ad490f795d8f5a7626e4d07943a6.tex']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./Plotting/plot_lce_triaddynamics_snaps&video.py", line 333, in <module>
plt.savefig(output_dir + "/SNAPS/Triad_SNAPS_{:05d}.png".format(2), format='png', dpi = 400)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/pyplot.py", line 723, in savefig
res = fig.savefig(*args, **kwargs)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 2203, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2126, in print_figure
**kwargs)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 514, in print_png
FigureCanvasAgg.draw(self)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 393, in draw
self.figure.draw(self.renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 1729, in draw
self.tight_layout(**self._tight_parameters)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 358, in wrapper
return func(*args, **kwargs)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/figure.py", line 2496, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/tight_layout.py", line 360, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/home/ecarroll/ecpy/lib/python3.6/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 "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/tight_layout.py", line 110, in <listcomp>
if ax.get_visible()])
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 4323, in get_tightbbox
bb_xaxis = self.xaxis.get_tightbbox(renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1188, in get_tightbbox
self._update_label_position(renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 2021, in _update_label_position
bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 2006, in _get_tick_boxes_siblings
tlb, tlb2 = axx.xaxis._get_tick_bboxes(ticks_to_draw, renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1174, in _get_tick_bboxes
for tick in ticks if tick.label1.get_visible()],
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/axis.py", line 1174, in <listcomp>
for tick in ticks if tick.label1.get_visible()],
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/text.py", line 905, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/text.py", line 300, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 204, in get_text_width_height_descent
s, fontsize, renderer=self)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 458, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 340, in make_dvi
texfile], tex)
File "/home/ecarroll/ecpy/lib/python3.6/site-packages/matplotlib/texmanager.py", line 319, in _run_checked_subprocess
exc=exc.output.decode('utf-8'))) from exc
RuntimeError: latex was not able to process the following string:
b'$\\\\mathdefault{0}$'
Here is the full report generated by latex:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(/home/ecarroll/.cache/matplotlib/tex.cache/f0d1ad490f795d8f5a7626e4d07943a6.te
x
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
! LaTeX Error: File `type1ec.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.6 \usepackage
{type1ec}^^M
No pages of output.
Transcript written on f0d1ad490f795d8f5a7626e4d07943a6.log.
Expected outcome
The expected outcome should be a plot where all the text and labels are rendered in Tex
Matplotlib version
Operating system: Ubuntu 18.04.3 LTS
Matplotlib version: matplotlib==3.2.2
Matplotlib backend (print(matplotlib.get_backend())): Default backend is TkAgg but I switch to use Agg in the code
Python version: 3.6.9
Jupyter version (if applicable):
Other libraries: Libraries in my virtual environment:
The problem is a missing latex package that we began to require someplace between mpl 2.1.1 and mpl 3.2.2.
See #16911 and links there in which chases back to #11381 .
I think the solution is to either get cm-super (which is the source of type1ec.sty https://ctan.org/pkg/cm-super) installed on your system by the sysadmins or get a local install of latex.
Bug report
Bug summary
Hi,
I am working on a linux system which I do not have root privileges to. As such, I have created a virtual environment so I can use modules as I need without installing them fully on the system.
I experienced an error when trying to use Latex as a text renderer for plots I am making for publication in my virtual environment.
I do not get an error and everything works fine when I run the same code snippet outside of my virtual environment and I need to work in my virtual environment as there are certain modules I need to compute other parts the code.
I am aware a similar issue was raised here the resolution appears to be reinstall/update whatever Tex distribution I have but I can not do that as I do not have root privileges on my system. So is there a work around I could use in my vitual environment?
Thanks in advance.
Code for reproduction
Actual outcome
Expected outcome
The expected outcome should be a plot where all the text and labels are rendered in Tex
Matplotlib version
print(matplotlib.get_backend())
): Default backend is TkAgg but I switch to use Agg in the codeLibraries in my virtual environment:
Libraries in my base Python:
The text was updated successfully, but these errors were encountered: