相关疑难解决方法(0)

是否存在matplotlib.ticker.LogFormatterSciNotation的非数学版本?

我试图使用对数y轴绘制图形pgf_with_latex,即所有文本格式都由pdflatex完成.在我的matplotlib rc参数中,我定义了一个要使用的字体.这是我的问题:标准matplotlib.ticker.LogFormatterSciNotation格式化程序使用数学文本,因此使用数学字体,它不适合其他字体(sans-serif).

如何使用格式化程序格式化y轴标签,matplotlib.ticker以便我获得标签格式为10的权力,并带有上标权限?更具体一点:我如何使用xticklabels中的字体以相同的方式格式化这些yticklabels?

我已经尝试过使用不同的格式化程序matplotlib.ticker,但是没有一个像我想要的那样编​​写指数.

以下是我对MWE的意思. 示例情节

import matplotlib as mpl

mpl.use('pgf')
pgf_with_latex = {
        "pgf.texsystem": "pdflatex",
        "font.family": "sans-serif",
        "text.usetex": False,
        "pgf.preamble": [
            r"\usepackage[utf8x]{inputenc}",
            r"\usepackage{tgheros}",  # TeX Gyre Heros sans serif
            r"\usepackage[T1]{fontenc}"
            ]
        }

mpl.rcParams.update(pgf_with_latex)
import matplotlib.pyplot as plt

fig = plt.figure(figsize=[3, 2])
ax = fig.add_subplot(111)
ax.set_yscale("log")
ax.minorticks_off()
ax.set_xlabel("sans-serif font label")
ax.set_ylabel("math font label")
plt.gca().set_ylim([1, 10000])
plt.gcf().tight_layout()


plt.savefig('{}.pdf'.format("test"))
Run Code Online (Sandbox Code Playgroud)

警告:必须在系统上安装TeX分发才能运行此分发.我使用了MikTex 2.9.还有Python 3.6.2和matplotlib 2.1.2.

python formatting plot latex matplotlib

7
推荐指数
1
解决办法
190
查看次数

如何显示Unicodes数值属性

'\u00BD' # ½
'\u00B2' # ²
Run Code Online (Sandbox Code Playgroud)

我试图更好地理解isdecimal()和isdigit(),因为它有必要理解unicode数值属性.我怎样才能看到例如上面两个unicodes的数值属性.

python unicode python-3.x

0
推荐指数
1
解决办法
745
查看次数

标签 统计

python ×2

formatting ×1

latex ×1

matplotlib ×1

plot ×1

python-3.x ×1

unicode ×1