From 1e6573541508cf7f6519b425178a2cc6e8d902f5 Mon Sep 17 00:00:00 2001 From: Midhul Date: Thu, 11 Jun 2020 19:52:47 -0400 Subject: [PATCH 1/2] Adde support for postscript eps terminal --- README.rst | 6 ++++++ gnuplot_kernel/epswrapper.py | 5 +++++ gnuplot_kernel/kernel.py | 3 +++ gnuplot_kernel/magics/gnuplot_magic.py | 5 +++-- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gnuplot_kernel/epswrapper.py diff --git a/README.rst b/README.rst index 9d90164..bb7948b 100644 --- a/README.rst +++ b/README.rst @@ -45,6 +45,12 @@ Requires - `Notebook`_ (IPython/Jupyter Notebook) - `Metakernel`_ +EPS terminal support requires ImageMagick and Wand: + +.. code-block:: bash + brew install imagemagick + pip install Wand + Documentation ============= diff --git a/gnuplot_kernel/epswrapper.py b/gnuplot_kernel/epswrapper.py new file mode 100644 index 0000000..042fb6c --- /dev/null +++ b/gnuplot_kernel/epswrapper.py @@ -0,0 +1,5 @@ +from wand.image import Image as WImage + +class EPS(WImage): + def __init__(self, filename): + super(EPS, self).__init__(filename=filename) \ No newline at end of file diff --git a/gnuplot_kernel/kernel.py b/gnuplot_kernel/kernel.py index 078912c..a1ef8cc 100644 --- a/gnuplot_kernel/kernel.py +++ b/gnuplot_kernel/kernel.py @@ -9,6 +9,7 @@ from .replwrap import GnuplotREPLWrapper, PROMPT from .exceptions import GnuplotError +from .epswrapper import EPS # This is the only place that the version is # specified @@ -232,6 +233,8 @@ def display_images(self): if self.inline_plotting: if settings['format'] == 'svg': _Image = SVG + elif settings['format'] == 'eps': + _Image = EPS else: _Image = Image diff --git a/gnuplot_kernel/magics/gnuplot_magic.py b/gnuplot_kernel/magics/gnuplot_magic.py index 7cf6af3..07f26c0 100644 --- a/gnuplot_kernel/magics/gnuplot_magic.py +++ b/gnuplot_kernel/magics/gnuplot_magic.py @@ -48,13 +48,14 @@ def line_gnuplot(self, *args): inline_terminals = {'pngcairo': 'png', 'png': 'png', 'jpeg': 'jpg', - 'svg': 'svg'} + 'svg': 'svg', + 'postscript': 'eps'} format = inline_terminals.get(terminal, 'png') if backend == 'inline': if terminal not in inline_terminals: msg = ("For inline plots, the terminal must be " - "one of pngcairo, jpeg, svg or png") + "one of pngcairo, jpeg, svg, png or postscript") raise ValueError(msg) self.kernel.plot_settings['backend'] = backend From b7e94cd8c3f6f735f7f9ab1778c798256f94bc63 Mon Sep 17 00:00:00 2001 From: midhul varma Date: Thu, 11 Jun 2020 19:54:07 -0400 Subject: [PATCH 2/2] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index bb7948b..dad1d20 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,7 @@ Requires EPS terminal support requires ImageMagick and Wand: .. code-block:: bash + brew install imagemagick pip install Wand