X Tutup
Skip to content

Calling subplots_adjust breaks savefig output #5946

@adamserafini

Description

@adamserafini

On Mac OSX, matplotlib==1.5.1, in a Virtualenv the following program saves the scattergraph output correctly to output.png:

import matplotlib
matplotlib.use('TkAgg')

import numpy as np
import matplotlib.pyplot as plt

if __name__ == '__main__':
    N = 50
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)
    area = np.pi * (15 * np.random.rand(N))**2
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)
    plt.savefig('output.png')

However, after introducing a call to subplots_adjust, the output in output.png is blank:

import matplotlib
matplotlib.use('TkAgg')

import numpy as np
import matplotlib.pyplot as plt

if __name__ == '__main__':
    N = 50
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)
    area = np.pi * (15 * np.random.rand(N))**2
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)
    plt.subplots_adjust(
        left=0.125,
        right=1.5,
        bottom=3.3,
        top=5,
        wspace=0.4,
        hspace=0.8)
    plt.savefig('output.png')  # results in a empty/blank .png

Is this a bug or am I using it wrong?

(I realise there are no subplots to adjust here: the above is a simplification, this was noticed in the context of a bigger script which does have subplots).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup