def embed(file_owner_or_url, file_id=None, width="100%", height=525): """Embeds existing Plotly figure in IPython Notebook Plotly uniquely identifies figures with a 'file_owner'/'file_id' pair. Since each file is given a corresponding unique url, you may also simply pass a valid plotly url as the first argument. Note, if you're using a file_owner string as the first argument, you MUST specify a `file_id` keyword argument. Else, if you're using a url string as the first argument, you MUST NOT specify a `file_id` keyword argument, or file_id must be set to Python's None value. Positional arguments: file_owner_or_url (string) -- a valid plotly username OR a valid plotly url Keyword arguments: file_id (default=None) -- an int or string that can be converted to int if you're using a url, don't fill this in! width (default="100%") -- an int or string corresp. to width of the figure height (default="525") -- same as width but corresp. to the height of the figure """ s = get_embed(file_owner_or_url, file_id, width, height) try: # see if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass try: from IPython.display import HTML, display display(HTML(s)) except: pass
def embed(username, plot_id, width="100%", height=525): s = get_embed(username, plot_id, width, height) try: # see if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass try: from IPython.display import HTML, display display(HTML(s)) except: pass
def embed(username, plot_id, width="100%", height=525): s = get_embed(username, plot_id, width, height) try: # see if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass try: from IPython.display import HTML return HTML(s) except: return s
def embed(file_owner_or_url, file_id=None, width="100%", height=525): """Embeds existing Plotly figure in IPython Notebook Plotly uniquely identifies figures with a 'file_owner'/'file_id' pair. Since each file is given a corresponding unique url, you may also simply pass a valid plotly url as the first argument. Note, if you're using a file_owner string as the first argument, you MUST specify a `file_id` keyword argument. Else, if you're using a url string as the first argument, you MUST NOT specify a `file_id` keyword argument, or file_id must be set to Python's None value. Positional arguments: file_owner_or_url (string) -- a valid plotly username OR a valid plotly url Keyword arguments: file_id (default=None) -- an int or string that can be converted to int if you're using a url, don't fill this in! width (default="100%") -- an int or string corresp. to width of the figure height (default="525") -- same as width but corresp. to the height of the figure """ try: s = get_embed(file_owner_or_url, file_id, width, height) # see if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass if _ipython_imported: if file_id: plotly_domain = ( session.get_session_config().get('plotly_domain') or get_config_file()['plotly_domain'] ) url = "{plotly_domain}/~{un}/{fid}".format( plotly_domain=plotly_domain, un=file_owner_or_url, fid=file_id) else: url = file_owner_or_url return PlotlyDisplay(url, width, height) else: warnings.warn( "Looks like you're not using IPython or Sage to embed this plot. " "If you just want the *embed code*, try using `get_embed()` " "instead." "\nQuestions? [email protected]")
def iplot(self, *args, **kwargs): ''' for use in ipython notebooks ''' res = self.__callplot(*args, **kwargs) width = kwargs.get('width', 600) height = kwargs.get('height', 450) s = '<iframe height="%s" id="igraph" scrolling="no" seamless="seamless" src="%s" width="%s"></iframe>' %\ (height+50, "/".join(map(str, [res['url'], width, height])), width+50) try: # see, if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass try: from IPython.display import HTML return HTML(s) except: return s
def display(url, width="100%", height=525, notebook=True): if isinstance( width, ( int, long ) ): s = '<iframe height="%s" id="igraph" scrolling="no" seamless="seamless" src="%s" width="%s"></iframe>' %\ (height+25, "/".join(map(str,[url, width, height])), width+25) else: s = '<iframe height="%s" id="igraph" scrolling="no" seamless="seamless" src="%s" width="%s"></iframe>' %\ (height+25, url, width) if not notebook: return s try: # see, if we are in the SageMath Cloud from sage_salvus import html return html(s, hide=False) except: pass try: from IPython.display import HTML return HTML(s) except: return s