diff --git a/plotly/plotly.py b/plotly/plotly.py
index 96a081ef764..07154d1fcb6 100644
--- a/plotly/plotly.py
+++ b/plotly/plotly.py
@@ -41,7 +41,14 @@ def iplot(self, *args, **kwargs):
res = self.__callplot(*args, **kwargs)
width = kwargs.get('width', 600)
height = kwargs.get('height', 600)
- s = ''
+ s = '' %\
+ (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)
@@ -169,11 +176,21 @@ def pandasJSONEncoder(self, obj):
except:
pass
return None
+ def sageJSONEncoder(self, obj):
+ try:
+ from sage.all import RR, ZZ
+ if obj in RR:
+ return float(obj)
+ elif obj in ZZ:
+ return int(obj)
+ except:
+ pass
+ return None
def default(self, obj):
try:
return json.dumps(obj)
except TypeError as e:
- encoders = (self.datetimeJSONEncoder, self.numpyJSONEncoder, self.pandasJSONEncoder)
+ encoders = (self.datetimeJSONEncoder, self.numpyJSONEncoder, self.pandasJSONEncoder, self.sageJSONEncoder)
for encoder in encoders:
s = encoder(obj)
if s is not None: