class_docstr: An embedded IPython instance to run inside Sphinx
class_docstr_tok: ["An","embedded","IPython","instance","to","run","inside","Sphinx"]
docstr: Ensures that pyplot has been imported into the embedded IPython shell.
  
  Also, makes sure to set the backend appropriately if not set already.
docstr_tok: ["Ensures","that","pyplot","has","been","imported","into","the","embedded","IPython","shell",".","Also",",","makes","sure","to","set","the","backend","appropriately","if","not","set","already","."]
code: def ensure_pyplot(self):
      """
      Ensures that pyplot has been imported into the embedded IPython shell.
  
      Also, makes sure to set the backend appropriately if not set already.
  
      """
      # We are here if the @figure pseudo decorator was used. Thus, it's
      # possible that we could be here even if python_mplbackend were set to
      # `None`. That's also strange and perhaps worthy of raising an
      # exception, but for now, we just set the backend to 'agg'.
  
      if not self._pyplot_imported:
          if "matplotlib.backends" not in sys.modules:
              # Then ipython_matplotlib was set to None but there was a
              # call to the @figure decorator (and ipython_execlines did
              # not set a backend).
              # raise Exception("No backend was set, but @figure was used!")
              import matplotlib
  
              matplotlib.use("agg")
  
          # Always import pyplot into embedded shell.
          self.process_input_line(
              "import matplotlib.pyplot as plt", store_history=False
          )
          self._pyplot_imported = True
  
imports: from __future__ import print_function
  import atexit
  import errno
  import os
  import re
  import sys
  import tempfile
  import ast
  import warnings
  import shutil
  from docutils.parsers.rst import directives
  from docutils.parsers.rst import Directive
  from traitlets.config import Config
  from IPython import InteractiveShell
  from IPython.core.profiledir import ProfileDir
  from IPython.utils import io
  from IPython.utils.py3compat import PY3
label_desc: Use image node_id 11 for calling the EmbeddedSphinxShell obj's underlying member method code with example usage: obj.ensure_pyplot() without return types