def show(self): r"""This will send any existing plots to the IPython notebook. If yt is being run from within an IPython session, and it is able to determine this, this function will send any existing plots to the notebook for display. If yt can't determine if it's inside an IPython session, it will raise YTNotInsideNotebook. Examples -------- >>> from yt.mods import SlicePlot >>> slc = SlicePlot(ds, "x", ["Density", "VelocityMagnitude"]) >>> slc.show() """ interactivity = self.plots[list(self.plots.keys())[0]].interactivity if interactivity: for k, v in sorted(iteritems(self.plots)): v.show() else: if "__IPYTHON__" in dir(builtins): from IPython.display import display display(self)
def show(self): r"""This will send any existing plots to the IPython notebook. If yt is being run from within an IPython session, and it is able to determine this, this function will send any existing plots to the notebook for display. If yt can't determine if it's inside an IPython session, it will raise YTNotInsideNotebook. Examples -------- >>> from yt.mods import SlicePlot >>> slc = SlicePlot(ds, "x", ["Density", "VelocityMagnitude"]) >>> slc.show() """ if "__IPYTHON__" in dir(builtins): api_version = get_ipython_api_version() if api_version in ('0.10', '0.11'): self._send_zmq() else: from IPython.display import display display(self) else: raise YTNotInsideNotebook
def _send_zmq(self): try: # pre-IPython v1.0 from IPython.zmq.pylab.backend_inline import send_figure as display except ImportError: # IPython v1.0+ from IPython.core.display import display for k, v in sorted(iteritems(self.plots)): # Due to a quirk in the matplotlib API, we need to create # a dummy canvas variable here that is never used. canvas = FigureCanvasAgg(v.figure) # NOQA display(v.figure)