8000 Style configuration changing behavior of savefig · Issue #9671 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Style configuration changing behavior of savefig #9671
Closed
@jasonrobwebster

Description

@jasonrobwebster

Hi,

I recently upgraded to Matplotlib 2.1.0 and for some reason my fig.savefig functionality has changed. Basically, it now requires a bytes-like object whenever a certain style file is used. Running the following code:

import numpy as np
import matplotlib.pyplot as plt
plt.style.use('aps')

x = np.linspace(0, 1, 100)
y = x**2

plt.plot(x, y)
fig = plt.gcf()

fig.savefig('test.pdf')

with the style configuration file 'aps' set to:

font.family	: serif
font.serif	: Times
font.size	: 8.0

text.usetex	: True

xtick.labelsize	: 8
xtick.direction	: in
xtick.major.size: 3

ytick.labelsize	: 8
ytick.direction	: in
ytick.major.size: 3

axes.labelsize	: 8
axes.titlesize	: 8

legend.fontsize	: 7

lines.linewidth	: 1
lines.markersize: 2

figure.figsize	: 3.417, 2.112
figure.dpi	: 100

figure.subplot.left	: 0.133
figure.subplot.right	: 0.99
figure.subplot.top	: 0.97
figure.subplot.bottom	: 0.16

savefig.dpi	: 600

I get

TypeError: a bytes-like object is required, not 'str'

at the line that involves the fig.savefig line. Weirdly, removing plt.style.use('aps') removes this error (but gives me the ugly default style).

Fixing this is simple enough on my side (replace the string with the bytes like obj), but this shouldn't be occurring in fig.savefig - thought I would bring it up.

Important info:
MPL version: 2.1.0
System: Windows 7 Ultimate
Tex backend is MikTex 2.9

Python version:
'3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]'

Regards,
jrw

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0