8000 Add Kaleido image export support by jonmmease · Pull Request #2613 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

Add Kaleido image export support #2613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jul 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1c18fe4
Add kaleido image export option behind the kaleido_export future flag
jonmmease Jul 3, 2020
7467329
Add CHANGELOG entry
jonmmease Jul 3, 2020
b546fcc
Add eps/emf formats
jonmmease Jul 7, 2020
7f65f5f
Replace future flag with engine kwarg
jonmmease Jul 7, 2020
556ef96
emf only available with kaleido
jonmmease Jul 7, 2020
ed71d6a
import kaleido submodule when plotly.io is imported
jonmmease Jul 8, 2020
da4cb83
Update Image renderers with engine parameter
jonmmease Jul 8, 2020
3e1cbd4
Added kaleido engine tests
jonmmease Jul 8, 2020
299165d
Merge remote-tracking branch 'origin/master' into kaleido
jonmmease Jul 8, 2020
411ffb4
Python 2.7 mock compatibility
jonmmease Jul 8, 2020
de44623
Python 2.7 mock compatibility
jonmmease Jul 8, 2020
c5f4e48
Update CHANGELOG.md
jonmmease Jul 8, 2020
4c5fe76
Add kaleido test that actually calls Kaleido and checks that the
jonmmease Jul 8, 2020
011ec72
Remove broken EMF format as option
jonmmease Jul 8, 2020
b5fc3db
Merge remote-tracking branch 'origin/master' into kaleido
jonmmease Jul 8, 2020
f8bff56
Remove broken EMF format as option
jonmmease Jul 8, 2020
827af91
Update image export documentation to recommend and describe Kaleido
jonmmease Jul 9, 2020
ef6e68d
Add engine docstring to figure image export methods
jonmmease Jul 9, 2020
fc7d856
Change kaleido conda channel to plotly since it most likely won't be …
jonmmease Jul 10, 2020
aee0e0d
Conda package renamed from kaleido -> python-kaleido
jonmmease Jul 12, 2020
32f6e7f
Merge remote-tracking branch 'origin/master' into kaleido
jonmmease Jul 13, 2020
00987c0
in README: indicate that Keleido is new and improved and orca is legacy
jonmmease Jul 14, 2020
a25f5b2
Add Kaleido note to orca-management section
jonmmease Jul 1 8000 4, 2020
a033df0
JPEG typo
jonmmease Jul 14, 2020
d1fc9a8
Merge "Install Dependency" sections and better explain that Kaleido i…
jonmmease Jul 14, 2020
2bdcfe2
Replace Orca with plotly.py when discussing supported image export fo…
jonmmease Jul 14, 2020
70c11ac
varying type
jonmmease Jul 14, 2020
e350025
factor typo [ci skip]
jonmmease Jul 14, 2020
967b728
Update CHANGELOG.md
jonmmease Jul 14, 2020
81a0bc7
Update doc/python/static-image-export.md
jonmmease Jul 14, 2020
74c4274
Update doc/python/orca-management.md
jonmmease Jul 14, 2020
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
Prev Previous commit
Next Next commit
Update Image renderers with engine parameter
Don't auto-start orca when image renderer is activated because now
we might not end up using orca.
  • Loading branch information
jonmmease committed Jul 8, 2020
commit da4cb83cf7c0ccb239c7dc7f11f3d51223c80875
41 changes: 22 additions & 19 deletions packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def __init__(
width=None,
height=None,
scale=None,
engine="auto",
):

self.mime_type = mime_type
Expand All @@ -120,10 +121,7 @@ def __init__(
self.width = width
self.height = height
self.scale = scale

def activate(self):
# Start up orca server to reduce the delay on first render
ensure_server()
self.engine = engine

def to_mimebundle(self, fig_dict):
image_bytes = to_image(
Expand All @@ -133,6 +131,7 @@ def to_mimebundle(self, fig_dict):
height=self.height,
scale=self.scale,
validate=False,
engine=self.engine,
)

if self.b64_encode:
Expand All @@ -146,83 +145,87 @@ def to_mimebundle(self, fig_dict):
class PngRenderer(ImageRenderer):
"""
Renderer to display figures as static PNG images. This renderer requires
the orca command-line utility and is broadly compatible across IPython
environments (classic Jupyter Notebook, JupyterLab, QtConsole, VSCode,
PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).
either the kaleido package or the orca command-line utility and is broadly
compatible across IPython environments (classic Jupyter Notebook, JupyterLab,
QtConsole, VSCode, PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).

mime type: 'image/png'
"""

def __init__(self, width=None, height=None, scale=None):
def __init__(self, width=None, height=None, scale=None, engine="auto"):
super(PngRenderer, self).__init__(
mime_type="image/png",
b64_encode=True,
format="png",
width=width,
height=height,
scale=scale,
engine=engine,
)


class SvgRenderer(ImageRenderer):
"""
Renderer to display figures as static SVG images. This renderer requires
the orca command-line utility and is broadly compatible across IPython
environments (classic Jupyter Notebook, JupyterLab, QtConsole, VSCode,
PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).
either the kaleido package or the orca command-line utility and is broadly
compatible across IPython environments (classic Jupyter Notebook, JupyterLab,
QtConsole, VSCode, PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).

mime type: 'image/svg+xml'
"""

def __init__(self, width=None, height=None, scale=None):
def __init__(self, width=None, height=None, scale=None, engine="auto"):
super(SvgRenderer, self).__init__(
mime_type="image/svg+xml",
b64_encode=False,
format="svg",
width=width,
height=height,
scale=scale,
engine=engine,
)


class JpegRenderer(ImageRenderer):
"""
Renderer to display figures as static JPEG images. This renderer requires
the orca command-line utility and is broadly compatible across IPython
environments (classic Jupyter Notebook, JupyterLab, QtConsole, VSCode,
PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).
either the kaleido package or the orca command-line utility and is broadly
compatible across IPython environments (classic Jupyter Notebook, JupyterLab,
QtConsole, VSCode, PyCharm, etc) and nbconvert targets (HTML, PDF, etc.).

mime type: 'image/jpeg'
"""

def __init__(self, width=None, height=None, scale=None):
def __init__(self, width=None, height=None, scale=None, engine="auto"):
super(JpegRenderer, self).__init__(
mime_type="image/jpeg",
b64_encode=True,
format="jpg",
width=width,
height=height,
scale=scale,
engine=engine,
)


class PdfRenderer(ImageRenderer):
"""
Renderer to display figures as static PDF images. This renderer requires
the orca command-line utility and is compatible with JupyterLab and the
LaTeX-based nbconvert export to PDF.
either the kaleido package or the orca command-line utility and is compatible
with JupyterLab and the LaTeX-based nbconvert export to PDF.

mime type: 'application/pdf'
"""

def __init__(self, width=None, height=None, scale=None):
def __init__(self, width=None, height=None, scale=None, engine="auto"):
super(PdfRenderer, self).__init__(
mime_type="application/pdf",
b64_encode=True,
format="pdf",
width=width,
height=height,
scale=scale,
engine=engine,
)


Expand Down
0