test before show

Hi,

How would you check that there is something to show() before you show()?

Thank you,

Douglas

···

--
View this message in context: http://www.nabble.com/test-before-show-tp22979149p22979149.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Although it is a bit inelegant, you could use the _pylab_helpers
module to see how many figure managers are active

home:~> ipython -pylab
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: plot([1,2,3])
Out[1]: [<matplotlib.lines.Line2D object at 0x46bfd70>]

In [2]: import matplotlib._pylab_helpers as _pylab_helpers

In [3]: print _pylab_helpers.Gcf.get_num_fig_managers()
1

JDH

···

On Thu, Apr 9, 2009 at 4:02 PM, mm2ps <dug@...2549...> wrote:

Hi,

How would you check that there is something to show() before you show()?

John Hunter wrote:

Hi,

How would you check that there is something to show() before you show()?

Although it is a bit inelegant, you could use the _pylab_helpers
module to see how many figure managers are active

In svn trunk this is exposed in pyplot.py:

len(pyplot.get_fignums())

should do it.

Eric

···

On Thu, Apr 9, 2009 at 4:02 PM, mm2ps <dug@...2549...> wrote:

home:~> ipython -pylab
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: plot([1,2,3])
Out[1]: [<matplotlib.lines.Line2D object at 0x46bfd70>]

In [2]: import matplotlib._pylab_helpers as _pylab_helpers

In [3]: print _pylab_helpers.Gcf.get_num_fig_managers()
1

JDH

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Dear Eric and John,

Thank both for your help.

John, I'll use your solution for now.

Eric, when it comes through my repository, I'll try your solution.

Again thanks.

Best,

Douglas

2009/4/13 Eric Firing <efiring@...202...>:

···

John Hunter wrote:

On Thu, Apr 9, 2009 at 4:02 PM, mm2ps <dug@...2549...> >> wrote:

Hi,

How would you check that there is something to show() before you show()?

Although it is a bit inelegant, you could use the _pylab_helpers
module to see how many figure managers are active

In svn trunk this is exposed in pyplot.py:

len(pyplot.get_fignums())

should do it.

Eric

home:~> ipython -pylab
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

Welcome to pylab, a matplotlib-based Python environment.
For more information, type 'help(pylab)'.

In [1]: plot([1,2,3])
Out[1]: [<matplotlib.lines.Line2D object at 0x46bfd70>]

In [2]: import matplotlib._pylab_helpers as _pylab_helpers

In [3]: print _pylab_helpers.Gcf.get_num_fig_managers()
1

JDH

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options