Skip to content

Commit

Permalink
Merge pull request #202 from wdecoster/kaleido
Browse files Browse the repository at this point in the history
using kaleido for static image generation from plotly
  • Loading branch information
wdecoster authored Sep 11, 2020
2 parents 60ae6c9 + 028df1d commit 9bfa4ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nanoplot/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.32.2"
__version__ = "1.33.0"
12 changes: 4 additions & 8 deletions nanoplotter/plot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import plotly.io as pio
from base64 import b64encode
from io import BytesIO
from urllib.parse import quote as urlquote
import sys
import logging
from kaleido.scopes.plotly import PlotlyScope


class Plot(object):
Expand Down Expand Up @@ -56,9 +55,6 @@ def show(self):
sys.stderr.write(".show not implemented for Plot instance without fig attribute!")

def save_static(self):
try:
pio.write_image(self.fig, self.path.replace('html', 'png'))
except ValueError as e:
logging.warning("Nanoplotter: orca not found, not creating static image of html. "
"See https://github.com/plotly/orca")
logging.warning(e, exc_info=True)
scope = PlotlyScope()
with open(self.path.replace('html', 'png'), "wb") as f:
f.write(scope.transform(self.fig, format="png"))
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
'nanomath>=1.0.0',
"pauvre==0.2.0",
'plotly>=4.1.0',
'pyarrow'
'pyarrow',
'kaleido'
],
package_data={'NanoPlot': []},
package_dir={'nanoplot': 'nanoplot'},
Expand Down

0 comments on commit 9bfa4ca

Please sign in to comment.