相关疑难解决方法(0)

输入带有日志图的1字体

我正在尝试使用Matplotlib图形作为相机就绪提交的一部分,并且出版社只需要使用Type 1字体.

我发现PDF后端很乐意为具有线性Y轴的简单图形输出Type-1字体,但是输出用于对数Y轴的Type-3字体.

使用对数yscale会导致使用mathtext,它似乎使用Type 3字体,可能是因为默认使用指数表示法.我可以使用一个丑陋的黑客来解决这个问题 - 使用pyplot.yticks()强制轴刻度不使用指数 - 但这需要移动绘图区域以容纳大标签(如10 ^ 6)或将轴写为10,100,1K等,所以它们适合.

我已经使用matplotlib master分支测试了下面的示例,以及1.1.1,它产生相同的行为,所以我不知道这是一个bug,可能只是意外的行为.

#!/usr/bin/env python
# Simple program to test for type 1 fonts. 
# Generate a line graph w/linear and log Y axes.

from matplotlib import rc, rcParams

rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
#rc('font',**{'family':'sans-serif','sans-serif':['computer modern sans serif']})

# These lines are needed to get type-1 results:
# http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
rcParams['ps.useafm'] = True
rcParams['pdf.use14corefonts'] = True
rcParams['text.usetex'] = False

import matplotlib.pyplot as plt

YSCALES = ['linear', 'log']

def plot(filename, yscale):
    plt.figure(1)
    xvals = range(1, 2) …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

11
推荐指数
2
解决办法
2843
查看次数

标签 统计

matplotlib ×1

python ×1