latex with graphical backend and svg savefig

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

latex with graphical backend and svg savefig

edgar
Hello,

1. I want to report a possible issue (I don't want an account on
GitHub... Micro$hit):

texmanager.py has

@ line 251:

         if rcParams['text.latex.unicode']:
             unicode_preamble = r"""
\usepackage[utf8]{inputenc}"""
         else:
             unicode_preamble = ''

@ line 299:

             if rcParams['text.latex.unicode']:
                 fh.write(s.encode('utf8'))

Due to font conflicts in my system [1], I need
   \usepackage{lmodern} \usepackage[QX]{fontenc}
(I tried with DejaVu Sans, without success). Adding it to the  rcParams  
in the  text.latex.preamble  does not help, because inputenc clashes
with that. In another computer, if I disable  text.latex.unicode ,
Matplotlib tries to use ASCII, which creates an error.

I suggest that the first conditional is removed (since  
text.latex.unicode  is depreceated anyway), but I don't know how the
unicode characters are going to be handled once that depreciation
happens (second conditional). Again, I didn't get that issue (ASCII)
with Parabola.


2. I want a SVG and to be able to show the figure on screen (possibly
save it from the new window). How can I achieve that?

This [2] didn't work.

     ! Font TS1/cmr/m/it/16=tcti1728 at 17.28pt not loadable: Metric
(TFM) file not
     found.
     <to be read again>
                    relax
     l.14 ...0000}{\rmfamily \textit{Velocity (°/sec)}
                                                   }

My failed attempt is below [3]

I tried to make this clear, but let me know if something needs
clarification. Thanks!


My system:
Parabola GNU/Linux
pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian)
matplotlib._version.get_versions()
{'dirty': False, 'error': None, 'full-revisionid':
'682e5195fae83393a75c71e84d1434cc9ff255fb', 'version': '3.0.1'}
(installed with pip)


[1] https://wiki.parabola.nu/TeXLive
[2]
https://matplotlib.org/gallery/text_labels_and_annotations/tex_demo.html#sphx-glr-gallery-text-labels-and-annotations-tex-demo-py
[3]

import matplotlib as mpl
from matplotlib import pyplot as pl
# https://tex.stackexchange.com/a/391078
# https://3diagramsperpage.wordpress.com/category/matplotlib/
family = "DejaVu Sans"
serif, sans_serif, mono = [family] * 3
size = 14
labelsize = 12
legfontsize = 10
ticksize = 10
pgf_with_latex = {  # setup matplotlib to use latex for output
     "text.usetex": True,   # use LaTeX to write all text
     # "text.latex.unicode": True,        #
https://github.com/MaxNoe/python-plotting/blob/master/source/siunitx_ticks.py
     "font.family": family,
     "font.serif": serif,  # blank entries should cause plots
     "font.sans-serif": sans_serif,  # to inherit fonts from the document
     "font.monospace": mono,
     # LaTeX default is 10pt font.
     "axes.labelsize": labelsize,
     "font.size": size,
     "legend.fontsize": legfontsize,  # Make the legend/label fonts
     "xtick.labelsize": ticksize,     # a little smaller
     "ytick.labelsize": ticksize,
     "text.latex.preamble": [
         # plots will be generated using this preamble
         # r"\usepackage[utf8x]{inputenc}",  # use utf8 fonts
         r"\usepackage{lmodern} \usepackage[QX]{fontenc}",
         r"\usepackage[detect-all]{siunitx}",
     ]
     }

mpl.rcParams.update(pgf_with_latex)

pl.plot([1e-6, 2e-6], label=r"μ")
pl.legend()
pl.show()

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users