Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions plotly/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
s = ("<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\""
"seamless=\"seamless\" "
"src=\"{plotly_rest_url}/"
"~{file_owner}/{file_id}/{plot_width}/{plot_height}\" "
"~{file_owner}/{file_id}.embed"
"?width={plot_width}&height={plot_height}\" "
"height=\"{iframe_height}\" width=\"{iframe_width}\">"
"</iframe>").format(
plotly_rest_url=plotly_rest_url,
Expand All @@ -259,7 +260,7 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
s = ("<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\""
"seamless=\"seamless\" "
"src=\"{plotly_rest_url}/"
"~{file_owner}/{file_id}\" "
"~{file_owner}/{file_id}.embed\" "
"height=\"{iframe_height}\" width=\"{iframe_width}\">"
"</iframe>").format(
plotly_rest_url=plotly_rest_url,
Expand Down Expand Up @@ -291,8 +292,8 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
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:
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)
Expand All @@ -306,7 +307,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
fid=file_id)
else:
url = file_owner_or_url
return PlotlyDisplay(url)
return PlotlyDisplay(url, width, height)
else:
warnings.warn(
"Looks like you're not using IPython or Sage to embed this plot. "
Expand Down Expand Up @@ -571,11 +572,14 @@ class PlotlyDisplay(IPython.core.display.HTML):
object can provide alternate representations.

"""
def __init__(self, url):
def __init__(self, url, width, height):
self.resource = url
self.embed_code = get_embed(url)
self.embed_code = get_embed(url, width=width, height=height)
super(PlotlyDisplay, self).__init__(data=self.embed_code)

def _repr_html_(self):
return self.embed_code

def _repr_svg_(self):
url = self.resource + ".svg"
res = requests.get(url)
Expand Down
2 changes: 1 addition & 1 deletion plotly/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.4'
__version__ = '1.4.5'