Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Warning:... GLib.source_remove(self._idle_draw_id) when using plt.savefig() #15773

@daniela-riveradiaz

Description

@daniela-riveradiaz

Bug summary
When saving plots with plt.savefig() I get the following warning:
/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_gtk3.py:197: Warning: Source ID 159 was not found when attempting to remove it
GLib.source_remove(self._idle_draw_id)

Code for reproduction

import matplotlib.pyplot as plt
x = [x/5 for x in range(1,101)]
y = [i for i in x]
plt.plot(x,y, label='line')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.show()
plt.savefig('fig_test')

Actual outcome
the result of plt.show() works fine:
image
but the saved image looks like this, either empty or deformed if the plot is more complex:
image

Expected outcome
The saved figure should look like the one from plt.show()

Matplotlib version

  • Operating system: Lubuntu 18.04
  • Other info in the screenshot:
    image

Matplotlib was installed with the following commands:
sudo python3 -m pip install -U pip
sudo python3 -m pip install -U matplotlib

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions