@@ -248,7 +248,8 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
248
248
s = ("<iframe id=\" igraph\" scrolling=\" no\" style=\" border:none;\" "
249
249
"seamless=\" seamless\" "
250
250
"src=\" {plotly_rest_url}/"
251
- "~{file_owner}/{file_id}/{plot_width}/{plot_height}\" "
251
+ "~{file_owner}/{file_id}.embed"
252
+ "?width={plot_width}&height={plot_height}\" "
252
253
"height=\" {iframe_height}\" width=\" {iframe_width}\" >"
253
254
"</iframe>" ).format (
254
255
plotly_rest_url = plotly_rest_url ,
@@ -259,7 +260,7 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
259
260
s = ("<iframe id=\" igraph\" scrolling=\" no\" style=\" border:none;\" "
260
261
"seamless=\" seamless\" "
261
262
"src=\" {plotly_rest_url}/"
262
- "~{file_owner}/{file_id}\" "
263
+ "~{file_owner}/{file_id}.embed \" "
263
264
"height=\" {iframe_height}\" width=\" {iframe_width}\" >"
264
265
"</iframe>" ).format (
265
266
plotly_rest_url = plotly_rest_url ,
@@ -291,8 +292,8 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
291
292
height (default="525") -- same as width but corresp. to the height of the figure
292
293
293
294
"""
294
- s = get_embed (file_owner_or_url , file_id , width , height )
295
295
try :
296
+ s = get_embed (file_owner_or_url , file_id , width , height )
296
297
# see if we are in the SageMath Cloud
297
298
from sage_salvus import html
298
299
return html (s , hide = False )
@@ -306,7 +307,7 @@ def embed(file_owner_or_url, file_id=None, width="100%", height=525):
306
307
fid = file_id )
307
308
else :
308
309
url = file_owner_or_url
309
- return PlotlyDisplay (url )
310
+ return PlotlyDisplay (url , width , height )
310
311
else :
311
312
warnings .warn (
312
313
"Looks like you're not using IPython or Sage to embed this plot. "
@@ -571,11 +572,14 @@ class PlotlyDisplay(IPython.core.display.HTML):
571
572
object can provide alternate representations.
572
573
573
574
"""
574
- def __init__ (self , url ):
575
+ def __init__ (self , url , width , height ):
575
576
self .resource = url
576
- self .embed_code = get_embed (url )
577
+ self .embed_code = get_embed (url , width = width , height = height )
577
578
super (PlotlyDisplay , self ).__init__ (data = self .embed_code )
578
579
580
+ def _repr_html_ (self ):
581
+ return self .embed_code
582
+
579
583
def _repr_svg_ (self ):
580
584
url = self .resource + ".svg"
581
585
res = requests .get (url )
0 commit comments