Skip to content

Commit

Permalink
Add pyplot 'interactive' functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Jul 21, 2020
1 parent 29943d8 commit cd44015
Showing 1 changed file with 63 additions and 7 deletions.
70 changes: 63 additions & 7 deletions proplot/ui.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
The starting point for creating custom ProPlot figures.
The starting point for creating ProPlot figures.
"""
import functools
import inspect
Expand All @@ -14,13 +14,26 @@
from . import gridspec as pgridspec
from .config import rc
from .internals import ic # noqa: F401
from .internals import _not_none, warnings
from .internals import _not_none, docstring, warnings
from .utils import units

__all__ = [
'close', 'show', 'subplots', 'SubplotsContainer', 'subplot_grid',
'close',
'ion',
'ioff',
'isinteractive',
'show',
'switch_backend',
'subplots',
'SubplotsContainer',
'subplot_grid',
]

docstring.snippets['pyplot.statement'] = """
This is included so you don't have to import `~matplotlib.pyplot`.
"""


# Width or (width, height) dimensions for common journal specifications
JOURNAL_SPECS = {
'aaas1': '5.5cm',
Expand All @@ -41,10 +54,11 @@
}


@docstring.add_snippets
def close(*args, **kwargs):
"""
Call `matplotlib.pyplot.close`. This is included so you don't have to import
`~matplotlib.pyplot`.
Call `matplotlib.pyplot.close`.
%(pyplot.statement)s
Parameters
----------
Expand All @@ -54,10 +68,38 @@ def close(*args, **kwargs):
plt.close(*args, **kwargs)


@docstring.add_snippets
def ion():
"""
Call `matplotlib.pyplot.ion`.
%(pyplot.statement)s
"""
plt.ion()


@docstring.add_snippets
def ioff():
"""
Call `matplotlib.pyplot.ioff`.
%(pyplot.statement)s
"""
plt.ioff()


@docstring.add_snippets
def isinteractive():
"""
Call `matplotlib.pyplot.isinteractive`.
%(pyplot.statement)s
"""
plt.isinteractive()


@docstring.add_snippets
def show(*args, **kwargs):
"""
Call `matplotlib.pyplot.show`. This is included so you don't have to import
`~matplotlib.pyplot`.
Call `matplotlib.pyplot.show`.
%(pyplot.statement)s
Parameters
----------
Expand All @@ -67,6 +109,20 @@ def show(*args, **kwargs):
plt.show(*args, **kwargs)


@docstring.add_snippets
def switch_backend(*args, **kwargs):
"""
Call `matplotlib.pyplot.switch_backend`.
%(pyplot.statement)s
Parameters
----------
*args, **kwargs
Passed to `matplotlib.pyplot.switch_backend`.
"""
plt.switch_backend(*args, **kwargs)


def _journals(journal):
"""
Return the width and height corresponding to the given journal.
Expand Down

0 comments on commit cd44015

Please sign in to comment.