Plz make JsROOT plots representable when converting to LaTeX using nbconvert
:
--- a/JupyROOT/helpers/utils.py 2020-04-22 19:44:27.144068951 +0300
+++ b/JupyROOT/helpers/utils.py 2020-04-22 19:30:35.847373018 +0300
@@ -391,6 +391,18 @@
def register(self):
self.shell.events.register('post_execute', self._post_execute)
+class HTMLwithPDF(HTML):
+ def __init__(self, data, drawableObject, **kwargs):
+ with tempfile.NamedTemporaryFile(suffix=".pdf") as ofile:
+ with _setIgnoreLevel(ROOT.kError):
+ drawableObject.SaveAs(ofile.name)
+ self._pdf = ofile.read()
+
+ super(HTMLwithPDF, self).__init__(data, **kwargs)
+
+ def _repr_mimebundle_(self, include=None, exclude=None):
+ return { 'application/pdf': self._pdf }
+
class NotebookDrawer(object):
'''
Capture the canvas which is drawn and decide if it should be displayed using
@@ -466,7 +478,7 @@
return thisJsCode
def _getJsDiv(self):
- return HTML(self._getJsCode())
+ return HTMLwithPDF(self._getJsCode(), self.drawableObject)
def _jsDisplay(self):
IPython.display.display(self._getJsDiv())