Repository: yt-project/yt

Issue:
Cannot save a slice plot as several image file formats except for eps, pdf, png, or ps
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**
<!--A short 1-2 sentences that succinctly describes the bug-->
`SlicePlot` object doesn't handle the image file specification correctly in the `save` method. If you specify image file formats except eps, pdf, png, or ps, the image is exported as PNG format.

**Code for reproduction**

<!--A minimum code snippet required to reproduce the bug, also minimizing the
number of dependencies required.-->

``` python
import yt
import matplotlib.pyplot as plt

supported_file_formats = plt.gcf().canvas.get_supported_filetypes()
print('Matplotlib supports:')
for k, v in supported_file_formats.items():
    print(k, v)

ds = yt.load('MOOSE_sample_data/out.e')
slc = yt.SlicePlot(ds, 'z', 'diffused', origin='native')
for ext in supported_file_formats.keys():
    print('Saving as ' + ext)
    slc.save('images/suffix_for_{:s}'.format(ext), suffix=ext)
```

<!-- If you need to use a data file to trigger the issue you're having, consider
using one of the datasets from the yt data hub (http://yt-project.org/data). If
your issue cannot be triggered using a public dataset, you can use the yt
curldrop (https://docs.hub.yt/services.html#curldrop) to share data
files. Please include a link to the dataset in the issue if you use the
curldrop.-->


**Actual outcome**
<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->
The actual output files are:
```
suffix_for_eps_Slice_z_diffused.eps  # OK
suffix_for_jpeg_Slice_z_diffused.jpeg.png
suffix_for_jpg_Slice_z_diffused.jpg.png
suffix_for_pdf_Slice_z_diffused.pdf  # OK
suffix_for_pgf_Slice_z_diffused.pgf.png
suffix_for_png_Slice_z_diffused.png  # OK
suffix_for_ps_Slice_z_diffused.ps  # OK
suffix_for_raw_Slice_z_diffused.raw.png
suffix_for_rgba_Slice_z_diffused.rgba.png
suffix_for_svg_Slice_z_diffused.svg.png
suffix_for_svgz_Slice_z_diffused.svgz.png
suffix_for_tif_Slice_z_diffused.tif.png
suffix_for_tiff_Slice_z_diffused.tiff.png
```

**Expected outcome**
Output files should be:
```
suffix_for_eps_Slice_z_diffused.eps
suffix_for_jpeg_Slice_z_diffused.jpeg
suffix_for_jpg_Slice_z_diffused.jpg
suffix_for_pdf_Slice_z_diffused.pdf
suffix_for_pgf_Slice_z_diffused.pgf
suffix_for_png_Slice_z_diffused.png
suffix_for_ps_Slice_z_diffused.ps
suffix_for_raw_Slice_z_diffused.raw
suffix_for_rgba_Slice_z_diffused.rgba
suffix_for_svg_Slice_z_diffused.svg
suffix_for_svgz_Slice_z_diffused.svgz
suffix_for_tif_Slice_z_diffused.tif
suffix_for_tiff_Slice_z_diffused.tiff

```

<!--A description of the expected outcome from the code snippet-->
<!--If this used to work in an earlier version of yt, please note the
version it used to work on-->


**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Mac OS X 10.14.5
  * Python Version: Python 3.5.2 :: Anaconda custom (x86_64)
  * yt version: cab1f48f982c28fbd1f8c1075ce3f1a0db5e686c
  * Other Libraries (if applicable): 

<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->




Discussion:
In Slack #help, @matthewturk said 
>So we use the `FigureCanvasAgg` for anything that isn't postscript or pdf.  Looks like the routine is just to see if it's asked for png, pdf, eps, ps, and if not, it uses Agg, which may or may not do the right thing with JPG.
Potentially related to issue #2310

Resolving patch:
diff --git a/yt/visualization/_mpl_imports.py b/yt/visualization/_mpl_imports.py
--- a/yt/visualization/_mpl_imports.py
+++ b/yt/visualization/_mpl_imports.py
@@ -9,3 +9,6 @@
 
 from matplotlib.backends.backend_ps import \
     FigureCanvasPS
+
+from matplotlib.backends.backend_svg import \
+    FigureCanvasSVG
diff --git a/yt/visualization/base_plot_types.py b/yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -48,6 +48,7 @@
                          'FigureManagerNbAgg'],
                 'agg': ['backend_agg', 'FigureCanvasAgg']}
 
+_AGG_FORMATS = (".png", ".jpg", ".jpeg", ".raw", ".rgba", ".tif", ".tiff")
 
 class CallbackWrapper(object):
     def __init__(self, viewer, window_plot, frb, field, font_properties,
@@ -133,7 +134,7 @@ def _set_canvas(self):
     def save(self, name, mpl_kwargs=None, canvas=None):
         """Choose backend and save image to disk"""
         from ._mpl_imports import \
-            FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
+            FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS, FigureCanvasSVG
         if mpl_kwargs is None:
             mpl_kwargs = {}
         if 'papertype' not in mpl_kwargs:
@@ -146,8 +147,10 @@ def save(self, name, mpl_kwargs=None, canvas=None):
 
         mylog.info("Saving plot %s", name)
 
-        if suffix == ".png":
+        if suffix in _AGG_FORMATS:
             canvas = FigureCanvasAgg(self.figure)
+        elif suffix in (".svg", ".svgz"):
+            canvas = FigureCanvasSVG(self.figure)
         elif suffix == ".pdf":
             canvas = FigureCanvasPdf(self.figure)
         elif suffix in (".eps", ".ps"):


Test patch: