更改图中

时间:2015-11-11 02:05:46

标签: python matplotlib

我想在python中创建类似IDL的图。我通过更改matplotlib目录中matplotlibrc文件中的一些细节来接近这样做。以下是我将matplotlibrc文件更改为标准matplotlibrc文件的内容:

     ### MATPLOTLIBRC FORMAT

backend      : tkagg

### LINES
lines.linewidth   : 1.1     # line width in points
lines.color       : black   # has no affect on plot(); see axes.color_cycle

### FONT
font.family         : sans-serif
font.weight         : ultralight
font.size           : 12.0
font.sans-serif     : Avant Garde

### TEXT

### LaTeX customizations. See http://www.scipy.org/Wiki/Cookbook/Matplotlib/UsingTex
text.usetex         : True  # use latex for all text handling. The following fonts
                              # are supported through the usual rc parameter settings:
                              # new century schoolbook, bookman, times, palatino,
                              # zapf chancery, charter, serif, sans-serif, helvetica,
                              # avant garde, courier, monospace, computer modern roman,
                              # computer modern sans serif, computer modern typewriter
                              # If another font is desired which can loaded using the
                              # LaTeX \usepackage command, please inquire at the
                              # matplotlib mailing list

mathtext.fontset : custom # Should be 'cm' (Computer Modern), 'stix',
                       # 'stixsans' or 'custom'

### AXES
axes.facecolor      : white   # axes background color

### TICKS
xtick.major.size     : 6      # major tick size in points
xtick.minor.size     : 3      # minor tick size in points
xtick.major.width    : 1    # major tick width in points
xtick.minor.width    : 1    # minor tick width in points

ytick.major.size     : 6      # major tick size in points
ytick.minor.size     : 3      # minor tick size in points
ytick.major.width    : 1    # major tick width in points
ytick.minor.width    : 1    # minor tick width in points

### GRIDS
legend.numpoints     : 1      # the number of points in the legend line
legend.frameon       : False   # whether or not to draw a frame around legend

### FIGURE
figure.figsize   : 4, 4    # figure size in inches
figure.dpi       : 100      # figure dots per inch
figure.facecolor : none    # figure facecolor; 0.75 is scalar gray
figure.edgecolor : white   # figure edgecolor

### SAVING FIGURES
savefig.dpi         : 1000      # figure dots per inch
savefig.format      : ps      # png, ps, pdf, svg
savefig.bbox        : tight # 'tight' or 'standard'.

显示了根据这些更改生成的绘图示例。请注意,输出(即绘图)用Avant Garde标记x和y轴(在matplotlibrc中具体说明),但数字不是Avatn Garde类型。如何使数字与图中的标签形成相同的字体,这样两者都是Avant Garde?另外,有没有办法让字体更窄(更薄),因此“初速度”这些词很薄(i.e., like Hershey vector fonts)?

1 个答案:

答案 0 :(得分:1)

您需要包含该行

text.latex.preamble : \usepackage{sfmath}

.matplotlibrc文件中。这告诉latex使用sans-serif字体作为数学文本,这是它用于刻度标签的。