Skip to content

The default backend (Qt4Agg) seems to change the figure size #7472

@Patrick5

Description

@Patrick5

The default backend (Qt4Agg) seems to be changing my figure size. The problem does not occur in AGG, TKAGG, or WEBAGG backends. I have not tested others.

Matplotlib version: 1.5.3 installed via anaconda
Python version: 3.5.2
Platform: Windows 8.1

The following is the minimal code I came up with that will reproduce the problem:

import matplotlib.pyplot as plt
fig = plt.figure()
print('size before:', fig.get_size_inches())
fig.canvas.flush_events()
fig.canvas.flush_events()
print('size after:', fig.get_size_inches())

This produces console output:
size before: [ 8. 6.]
size after: [ 8. 5.95]

In more general use this typically arises after a couple of frames have been displayed, and specifically causes a problem when making a movie from those displayed images: the output rolls by 5 pixels from frame to frame. Playing back the resulting mp4 looks like an old analog TV with the vertical sync out of whack.

BTW, one workaround is to call fig.set_size_inches(8,6) after the second flush above but before any frames are generated or grabbed, as the size does not seem to get changed again.

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