X Tutup
Skip to content

interactive mode doesn't display images with standard python interpreter #5561

@wlnirvana

Description

@wlnirvana

All the codes won't display images, and there is a warning when I try to exit from python shell, which I don't know if is relevant.

############################################################
# first try using pylab
############################################################
>>> from pylab import *
>>> matplotlib.interactive(True)
>>> matplotlib.is_interactive()
True
>>> plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x7ff821558290>]
>>>                                            # <--------------- press Ctrl-D here
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py:219: Warning: Source ID 8 was not found when attempting to remove it
  GLib.source_remove(self._idle_draw_id)

############################################################
# second try using ion()
############################################################
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> plt.plot([1,2,3])                          # No image displayed
[<matplotlib.lines.Line2D object at 0x7f940c91b790>]
>>> plt.show()                                 # still no image displayed
>>>                                            # <--------------- press Ctrl-D here
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py:219: Warning: Source ID 8 was not found when attempting to remove it
  GLib.source_remove(self._idle_draw_id)

############################################################
# third try using show() with interactive mode
############################################################
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x7efe545b2790>]
>>> plt.show()                                 # no image displayed
>>>                                            # <--------------- press Ctrl-D here
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py:219: Warning: Source ID 8 was not found when attempting to remove it
  GLib.source_remove(self._idle_draw_id)

However if interactive mode is not used, everything is fine. After I close the image window and exit python shell later on, there is no warning.

>>> import matplotlib.pyplot as plt
p>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x7f534d7da7d0>]
>>> plt.show()                                 # image pops up

Below is my environment information:

$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt17-1 (2015-09-26) x86_64 GNU/Linux
$ python
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.5.0'
>>> matplotlib.get_backend()
u'GTK3Agg'

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