Python Matplotlib某些乳胶符号不随图形大小的增加而缩放

Python Matplotlib某些乳胶符号不随图形大小的增加而缩放,python,matplotlib,latex,Python,Matplotlib,Latex,解决方案 修复方法是使用所述的fixcmex。此外,还表明这是底层乳胶的一个问题 我注意到,当我将图形大小增加到一些非常大的尺寸(用于非常大的非主监视器)时,并不是所有的LaTeX符号都能正确缩放 例如 当我使用非常小的图形尺寸(适合默认显示器尺寸)时,一切似乎都很好: 但是,当我增加图形尺寸时,并非所有符号都会缩放 好的 坏的 和丑陋的人 一些问题符号包括int、frac、sqrt(显示样式)和缩放括号 为什么要提到默认的Ubuntu显示? 我知道Matplotlib在画布大于默认窗口

解决方案
修复方法是使用所述的
fixcmex
。此外,还表明这是底层乳胶的一个问题

我注意到,当我将图形大小增加到一些非常大的尺寸(用于非常大的非主监视器)时,并不是所有的LaTeX符号都能正确缩放

例如

当我使用非常小的图形尺寸(适合默认显示器尺寸)时,一切似乎都很好:

但是,当我增加图形尺寸时,并非所有符号都会缩放

好的

坏的

和丑陋的人

一些问题符号包括
int
frac
sqrt
(显示样式)和缩放括号

为什么要提到默认的Ubuntu显示?

我知道Matplotlib在画布大于默认窗口大小时存在一些问题,例如,和)

代码:

在Ubuntu 16.04上使用虚拟环境python 2.7.12和matplotlib 2.2.3以及TkAgg后端。(不完全是MWE,但我希望距离足够近)


没想到会在这里见到埃尼奥·莫里康
import matplotlib as mpl
plt_style = 1 # Toggle this to see the difference
if plt_style == 0:  
    rc_fonts = {
        "text.usetex": True,
        "font.size": 30,
        'mathtext.default': 'regular',
        'axes.titlesize': 33,
        "axes.labelsize": 33,
        "legend.fontsize": 30,
        "xtick.labelsize": 30,
        "ytick.labelsize": 30,
        'figure.titlesize': 33,
        'figure.figsize': (15,9.3),
        'text.latex.preamble': [r'\usepackage{amsmath,amssymb,bm,physics,lmodern}'],
        "font.family": "serif",
        "font.serif": "computer modern roman",
        }
elif plt_style == 1:
    rc_fonts = {
        "text.usetex": True,
        "font.size": 50,
        'mathtext.default': 'regular',
        'axes.titlesize': 55,
        "axes.labelsize": 55,
        "legend.fontsize": 50,
        "xtick.labelsize": 50,
        "ytick.labelsize": 50,
        'figure.titlesize': 55,
        'figure.figsize': (25, 16.5),  # 15, 9.3
        'text.latex.preamble': [r'\usepackage{amsmath,amssymb,bm,fontenc,physics,lmodern,nicefrac}'],
        "font.family": "serif",
        "font.serif": "computer modern roman",
    }
elif plt_style == 2:
    rc_fonts = {
        "text.usetex": True,
        "font.size": 15,
        'mathtext.default': 'regular',
        'axes.titlesize': 16,
        "axes.labelsize": 16,
        "legend.fontsize": 15,
        "xtick.labelsize": 15,
        "ytick.labelsize": 15,
        'figure.titlesize': 16,
        'figure.figsize': (7.5,4.65),
        'text.latex.preamble': [r'\usepackage{amsmath,amssymb,bm,physics,lmodern}'],
        "font.family": "serif",
        "font.serif": "computer modern roman",
        }
mpl.rcParams.update(rc_fonts)
import matplotlib.pylab as plt
import pandas as pd
import numpy as np

# e.g. An example plot

x = np.linspace(-3, 3, 1000)
y1 = np.exp(-0.5*x**2)/np.sqrt(2.0*np.pi)
y2 = np.sin(x)**2.0*np.exp(-0.5*x**2)/np.sqrt(2.0*np.pi)
plt.clf()  # I usually clear the current figure.
plt.plot(x, y1, 'k-', label='Standard Gaussian')
plt.plot(x, y2, 'r-', label='Modified Gaussian')
plt.legend(loc='upper left', frameon=False)
plt.title('Gaussian functions', y=1.02)  # A small vertical offset is usually nice.
plt.xlabel(r'$x$')
plt.ylabel(r'$f(x)$')
plt.ylim((0, 0.5))
plt.xlim((min(x), max(x)))
plt.gca().text(0.98, 0.98, r'$\displaystyle\int_\mathbb{R}^{} \sqrt{\dfrac{1}{\sqrt{2\pi\sigma}} \exp(-\dfrac{x^2}{2\sigma^2})} \dd{x} = 1 $', transform=plt.gca().transAxes, horizontalalignment='right', verticalalignment='top')
# plt.savefig('figures/gaussian_{}.pdf'.format(plt_style), format='pdf', bbox_inches='tight', transparent=True)