[yt-svn] commit/yt: 21 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Aug 3 07:07:10 PDT 2016
21 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/086ecb555a30/
Changeset: 086ecb555a30
Branch: yt
User: a_gilbert
Date: 2016-07-18 18:07:20+00:00
Summary: Made all plots compatible with matplotlib supported backends.
Affected #: 5 files
diff -r 0a704f6bd0096052e97d0c338266b7c4d2ea2379 -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab yt/analysis_modules/level_sets/clump_handling.py
--- a/yt/analysis_modules/level_sets/clump_handling.py
+++ b/yt/analysis_modules/level_sets/clump_handling.py
@@ -85,7 +85,7 @@
if self.children is None: return
for child in self.children:
child.add_validator(validator)
-
+
def add_info_item(self, info_item, *args, **kwargs):
"Adds an entry to clump_info list and tells children to do the same."
diff -r 0a704f6bd0096052e97d0c338266b7c4d2ea2379 -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -668,7 +668,7 @@
sfh.update({0:data})
grid_left_edges = domain_left_edge
grid_right_edges = domain_right_edge
- grid_dimensions = domain_dimensions.reshape(nprocs,3).astype("int32")
+ grid_dimensions = domain_dimensions.reshape(nprocs, len(domain_dimensions)).astype("int32")
if length_unit is None:
length_unit = 'code_length'
diff -r 0a704f6bd0096052e97d0c338266b7c4d2ea2379 -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,6 +23,25 @@
matplotlib_style_context
import numpy as np
+backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
+ 'FigureManagerGTK'],
+ 'GTKAgg': ['backend_gtkagg', 'FigureCanvasGTKAgg'],
+ 'GTKCairo': ['backend_gtkcairo', 'FigureCanvasGTKCairo'],
+ 'MacOSX': ['backend_macosx', 'FigureCanvasMac', 'FigureManagerMac'],
+ 'Qt4Agg': ['backend_qt4agg', 'FigureCanvasQTAgg'],
+ 'Qt5Agg': ['backend_gt5agg', 'FigureCanvasQTAgg'],
+ 'TkAgg': ['backend_tkagg', 'FigureCanvasTkAgg'],
+ 'WX': ['backend_wx', 'FigureCanvasWx'],
+ 'WXAgg': ['backend_wxagg', 'FigureCanvasWxAgg'],
+ 'GTK3Cairo': ['backend_gtk3cairo',
+ 'FigureCanvasGTK3Cairo',
+ 'FigureManagerGTK3Cairo'],
+ 'GTK3Agg': ['backend_gtk3agg', 'FigureCanvasGTK3Agg',
+ 'FigureManagerGTK3Agg'],
+ 'WebAgg': ['backend_webagg', 'FigureCanvasWebAgg'],
+ 'nbAgg': ['backend_nbagg', 'FigureCanvasNbAgg',
+ 'FigureManagerNbAgg']}
+
class CallbackWrapper(object):
def __init__(self, viewer, window_plot, frb, field, font_properties,
@@ -50,14 +69,29 @@
self.font_color = font_color
self.field = field
+
+def _set_canvas():
+ backend = str(matplotlib.get_backend())
+ for key in backend_dict.keys():
+ if key == backend:
+ mod = __import__('matplotlib.backends', globals(), locals(),
+ [backend_dict[key][0]], -1)
+ submod = getattr(mod, backend_dict[key][0])
+ FigureCanvas = getattr(submod, backend_dict[key][1])
+ if len(backend_dict[key]) > 2:
+ FigureManager = getattr(submod, backend_dict[key][2])
+ return [FigureCanvas, FigureManager]
+ else:
+ return [FigureCanvas]
+
+
class PlotMPL(object):
- """A base class for all yt plots made using matplotlib.
+ """A base class for all yt plots made using matplotlib, that is backend independent.
"""
- def __init__(self, fsize, axrect, figure, axes):
+ def __init__(self, fsize, axrect, figure, axes, backend_classes=_set_canvas()):
"""Initialize PlotMPL class"""
import matplotlib.figure
- from ._mpl_imports import FigureCanvasAgg
self._plot_valid = True
if figure is None:
self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
@@ -70,7 +104,9 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- self.canvas = FigureCanvasAgg(self.figure)
+ self.canvas = backend_classes[0](self.figure)
+ if len(backend_classes) > 1:
+ self.manager = backend_classes[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
self.axes.tick_params(which=which, axis=axis, direction='in')
@@ -105,6 +141,12 @@
canvas.print_figure(name, **mpl_kwargs)
return name
+ def show(self):
+ try:
+ self.manager.show()
+ except AttributeError:
+ self.canvas.show()
+
def _get_labels(self):
ax = self.axes
labels = ax.xaxis.get_ticklabels() + ax.yaxis.get_ticklabels()
diff -r 0a704f6bd0096052e97d0c338266b7c4d2ea2379 -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -622,8 +622,11 @@
if api_version in ('0.10', '0.11'):
self._send_zmq()
else:
- from IPython.display import display
- display(self)
+ #from IPython.display import display
+ #display(self)
+ for k,v in sorted(iteritems(self.plots)):
+ v.show()
+
else:
raise YTNotInsideNotebook
diff -r 0a704f6bd0096052e97d0c338266b7c4d2ea2379 -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -144,7 +144,8 @@
Parameters
----------
- data_source : :class:`yt.data_objects.construction_data_containers.YTQuadTreeProj` or :class:`yt.data_objects.selection_data_containers.YTSlice`
+ data_source : :class:`yt.data_objects.construction_data_containers.YTQuadTreeProj`
+ or :class:`yt.data_objects.selection_data_containers.YTSlice`
This is the source to be pixelized, which can be a projection or a
slice. (For cutting planes, see
`yt.visualization.fixed_resolution.ObliqueFixedResolutionBuffer`.)
https://bitbucket.org/yt_analysis/yt/commits/2774cf973b85/
Changeset: 2774cf973b85
Branch: yt
User: a_gilbert
Date: 2016-07-19 19:08:05+00:00
Summary: Trying a workaround for interactivity
Affected #: 6 files
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -155,7 +155,8 @@
ProjectionPlot, OffAxisProjectionPlot, \
show_colormaps, add_cmap, make_colormap, \
ProfilePlot, PhasePlot, ParticlePhasePlot, \
- ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot
+ ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
+ ioff
from yt.visualization.volume_rendering.api import \
volume_render, create_scene, ColorTransferFunction, TransferFunction, \
@@ -168,7 +169,7 @@
parallel_objects, enable_parallelism, communication_system
from yt.convenience import \
- load, simulation
+ load, simulation, ion, ioff
from yt.testing import run_nose
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/convenience.py
--- a/yt/convenience.py
+++ b/yt/convenience.py
@@ -127,4 +127,3 @@
return simulation_time_series_registry[simulation_type](parameter_filename,
find_outputs=find_outputs)
-
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -986,3 +986,4 @@
except ImportError:
pass
return dummy_context_manager()
+
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -58,4 +58,5 @@
PhasePlot
from .base_plot_types import \
- get_multi_plot
+ get_multi_plot, \
+ ioff
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -40,7 +40,8 @@
'FigureManagerGTK3Agg'],
'WebAgg': ['backend_webagg', 'FigureCanvasWebAgg'],
'nbAgg': ['backend_nbagg', 'FigureCanvasNbAgg',
- 'FigureManagerNbAgg']}
+ 'FigureManagerNbAgg'],
+ 'Agg': ['backend_agg', 'FigureCanvasAgg']}
class CallbackWrapper(object):
@@ -69,20 +70,22 @@
self.font_color = font_color
self.field = field
+def ioff():
+ matplotlib.use('Agg')
def _set_canvas():
- backend = str(matplotlib.get_backend())
- for key in backend_dict.keys():
- if key == backend:
- mod = __import__('matplotlib.backends', globals(), locals(),
- [backend_dict[key][0]], -1)
- submod = getattr(mod, backend_dict[key][0])
- FigureCanvas = getattr(submod, backend_dict[key][1])
- if len(backend_dict[key]) > 2:
- FigureManager = getattr(submod, backend_dict[key][2])
- return [FigureCanvas, FigureManager]
- else:
- return [FigureCanvas]
+ backend = str(matplotlib.get_backend())
+ for key in backend_dict.keys():
+ if key == backend:
+ mod = __import__('matplotlib.backends', globals(), locals(),
+ [backend_dict[key][0]], -1)
+ submod = getattr(mod, backend_dict[key][0])
+ FigureCanvas = getattr(submod, backend_dict[key][1])
+ if len(backend_dict[key]) > 2:
+ FigureManager = getattr(submod, backend_dict[key][2])
+ return [FigureCanvas, FigureManager]
+ else:
+ return [FigureCanvas]
class PlotMPL(object):
diff -r 086ecb555a30417b433fcc07e0e3c492bb94d4ab -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -617,15 +617,17 @@
>>> slc.show()
"""
- if "__IPYTHON__" in dir(builtins):
- api_version = get_ipython_api_version()
- if api_version in ('0.10', '0.11'):
- self._send_zmq()
- else:
- #from IPython.display import display
- #display(self)
- for k,v in sorted(iteritems(self.plots)):
- v.show()
+ for k,v in sorted(iteritems(self.plots)):
+ v.show()
+# if "__IPYTHON__" in dir(builtins):
+# api_version = get_ipython_api_version()
+# if api_version in ('0.10', '0.11'):
+# self._send_zmq()
+# else:
+# #from IPython.display import display
+# #display(self)
+# for k,v in sorted(iteritems(self.plots)):
+# v.show()
else:
raise YTNotInsideNotebook
https://bitbucket.org/yt_analysis/yt/commits/ebf3f891eb1b/
Changeset: ebf3f891eb1b
Branch: yt
User: a_gilbert
Date: 2016-07-19 19:13:59+00:00
Summary: bug fix
Affected #: 1 file
diff -r 2774cf973b85219c0c4ba9dd4c21ef2ba53fe773 -r ebf3f891eb1b7b49aeb8decc737afacccdd419fe yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -169,7 +169,7 @@
parallel_objects, enable_parallelism, communication_system
from yt.convenience import \
- load, simulation, ion, ioff
+ load, simulation
from yt.testing import run_nose
https://bitbucket.org/yt_analysis/yt/commits/48710b02b5d1/
Changeset: 48710b02b5d1
Branch: yt
User: a_gilbert
Date: 2016-07-19 19:24:05+00:00
Summary: bug fix, part 2: the electric boogaloo
Affected #: 1 file
diff -r ebf3f891eb1b7b49aeb8decc737afacccdd419fe -r 48710b02b5d137a6a9e90a448d0ff280828d4b67 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -41,7 +41,7 @@
'WebAgg': ['backend_webagg', 'FigureCanvasWebAgg'],
'nbAgg': ['backend_nbagg', 'FigureCanvasNbAgg',
'FigureManagerNbAgg'],
- 'Agg': ['backend_agg', 'FigureCanvasAgg']}
+ 'agg': ['backend_agg', 'FigureCanvasAgg']}
class CallbackWrapper(object):
@@ -71,7 +71,7 @@
self.field = field
def ioff():
- matplotlib.use('Agg')
+ matplotlib.rcParams['backend'] = 'Agg'
def _set_canvas():
backend = str(matplotlib.get_backend())
https://bitbucket.org/yt_analysis/yt/commits/bb1491a98143/
Changeset: bb1491a98143
Branch: yt
User: a_gilbert
Date: 2016-07-19 19:34:57+00:00
Summary: bug fix, part 3: it may not be a bug, but a fundamental error in my logic.
Affected #: 1 file
diff -r 48710b02b5d137a6a9e90a448d0ff280828d4b67 -r bb1491a98143535a7ea3db48fbd7ed0bf84dac1a yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -23,7 +23,9 @@
from distutils.version import LooseVersion
from numbers import Number
-from .base_plot_types import ImagePlotMPL
+from .base_plot_types import \
+ ImagePlotMPL, \
+ ioff
from .fixed_resolution import \
FixedResolutionBuffer, \
ObliqueFixedResolutionBuffer, \
https://bitbucket.org/yt_analysis/yt/commits/ff1384de9beb/
Changeset: ff1384de9beb
Branch: yt
User: a_gilbert
Date: 2016-07-19 21:55:35+00:00
Summary: blessed are the class variables, for they are problem solvers.
Affected #: 3 files
diff -r bb1491a98143535a7ea3db48fbd7ed0bf84dac1a -r ff1384de9bebd0ed5226d9012c0b213f23ae2c95 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -155,8 +155,7 @@
ProjectionPlot, OffAxisProjectionPlot, \
show_colormaps, add_cmap, make_colormap, \
ProfilePlot, PhasePlot, ParticlePhasePlot, \
- ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
- ioff
+ ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot
from yt.visualization.volume_rendering.api import \
volume_render, create_scene, ColorTransferFunction, TransferFunction, \
diff -r bb1491a98143535a7ea3db48fbd7ed0bf84dac1a -r ff1384de9bebd0ed5226d9012c0b213f23ae2c95 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -58,5 +58,4 @@
PhasePlot
from .base_plot_types import \
- get_multi_plot, \
- ioff
+ get_multi_plot
diff -r bb1491a98143535a7ea3db48fbd7ed0bf84dac1a -r ff1384de9bebd0ed5226d9012c0b213f23ae2c95 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -70,9 +70,6 @@
self.font_color = font_color
self.field = field
-def ioff():
- matplotlib.rcParams['backend'] = 'Agg'
-
def _set_canvas():
backend = str(matplotlib.get_backend())
for key in backend_dict.keys():
@@ -92,7 +89,10 @@
"""A base class for all yt plots made using matplotlib, that is backend independent.
"""
- def __init__(self, fsize, axrect, figure, axes, backend_classes=_set_canvas()):
+
+ interactive = False
+
+ def __init__(self, fsize, axrect, figure, axes):
"""Initialize PlotMPL class"""
import matplotlib.figure
self._plot_valid = True
@@ -107,13 +107,40 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- self.canvas = backend_classes[0](self.figure)
- if len(backend_classes) > 1:
- self.manager = backend_classes[1](self.canvas, 1)
+ canvasClasses = PlotMPL.set_canvas()
+ self.canvas = canvasClasses[0]
+ if len(canvasClasses) > 1:
+ self.manager = canvasClasses[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
self.axes.tick_params(which=which, axis=axis, direction='in')
+ @classmethod
+ def _set_canvas(cls):
+ if PlotMPL.interactive:
+ backend = str(matplotlib.get_backend())
+ else:
+ backend = 'agg'
+ for key in backend_dict.keys():
+ if key == backend:
+ mod = __import__('matplotlib.backends', globals(), locals(),
+ [backend_dict[key][0]], -1)
+ submod = getattr(mod, backend_dict[key][0])
+ FigureCanvas = getattr(submod, backend_dict[key][1])
+ if len(backend_dict[key]) > 2:
+ FigureManager = getattr(submod, backend_dict[key][2])
+ return [FigureCanvas, FigureManager]
+ else:
+ return [FigureCanvas]
+
+ @classmethod
+ def ion(cls):
+ cls.interactive = True
+
+ @classmethod
+ def ioff(cls):
+ cls.interactive = False
+
def save(self, name, mpl_kwargs=None, canvas=None):
"""Choose backend and save image to disk"""
from ._mpl_imports import \
https://bitbucket.org/yt_analysis/yt/commits/2b2badfd7159/
Changeset: 2b2badfd7159
Branch: yt
User: a_gilbert
Date: 2016-07-19 21:58:23+00:00
Summary: blessed are the class variables, for they are problem solvers 2: the electric boogaloo.
Affected #: 1 file
diff -r ff1384de9bebd0ed5226d9012c0b213f23ae2c95 -r 2b2badfd71590210f0ad145b459379b4c8cee67e yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -24,8 +24,7 @@
from numbers import Number
from .base_plot_types import \
- ImagePlotMPL, \
- ioff
+ ImagePlotMPL
from .fixed_resolution import \
FixedResolutionBuffer, \
ObliqueFixedResolutionBuffer, \
https://bitbucket.org/yt_analysis/yt/commits/05fd0b730587/
Changeset: 05fd0b730587
Branch: yt
User: a_gilbert
Date: 2016-07-19 22:03:31+00:00
Summary: Underscores are important
Affected #: 1 file
diff -r 2b2badfd71590210f0ad145b459379b4c8cee67e -r 05fd0b7305873b46f0228ff90ac73cf02d6a71fd yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -107,7 +107,7 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- canvasClasses = PlotMPL.set_canvas()
+ canvasClasses = PlotMPL._set_canvas()
self.canvas = canvasClasses[0]
if len(canvasClasses) > 1:
self.manager = canvasClasses[1](self.canvas, 1)
https://bitbucket.org/yt_analysis/yt/commits/6e1c2aa8c614/
Changeset: 6e1c2aa8c614
Branch: yt
User: a_gilbert
Date: 2016-07-19 22:34:57+00:00
Summary: Finalized docs
Affected #: 2 files
diff -r 05fd0b7305873b46f0228ff90ac73cf02d6a71fd -r 6e1c2aa8c6141c655bf6d0855c957a66d251415f yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -70,20 +70,6 @@
self.font_color = font_color
self.field = field
-def _set_canvas():
- backend = str(matplotlib.get_backend())
- for key in backend_dict.keys():
- if key == backend:
- mod = __import__('matplotlib.backends', globals(), locals(),
- [backend_dict[key][0]], -1)
- submod = getattr(mod, backend_dict[key][0])
- FigureCanvas = getattr(submod, backend_dict[key][1])
- if len(backend_dict[key]) > 2:
- FigureManager = getattr(submod, backend_dict[key][2])
- return [FigureCanvas, FigureManager]
- else:
- return [FigureCanvas]
-
class PlotMPL(object):
"""A base class for all yt plots made using matplotlib, that is backend independent.
@@ -121,6 +107,7 @@
backend = str(matplotlib.get_backend())
else:
backend = 'agg'
+
for key in backend_dict.keys():
if key == backend:
mod = __import__('matplotlib.backends', globals(), locals(),
@@ -135,10 +122,12 @@
@classmethod
def ion(cls):
+ """Toggles interactive backends on."""
cls.interactive = True
@classmethod
def ioff(cls):
+ """Toggles interactive backends off."""
cls.interactive = False
def save(self, name, mpl_kwargs=None, canvas=None):
diff -r 05fd0b7305873b46f0228ff90ac73cf02d6a71fd -r 6e1c2aa8c6141c655bf6d0855c957a66d251415f yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -619,18 +619,6 @@
"""
for k,v in sorted(iteritems(self.plots)):
v.show()
-# if "__IPYTHON__" in dir(builtins):
-# api_version = get_ipython_api_version()
-# if api_version in ('0.10', '0.11'):
-# self._send_zmq()
-# else:
-# #from IPython.display import display
-# #display(self)
-# for k,v in sorted(iteritems(self.plots)):
-# v.show()
-
- else:
- raise YTNotInsideNotebook
@validate_plot
def display(self, name=None, mpl_kwargs=None):
https://bitbucket.org/yt_analysis/yt/commits/4de95db7c1c4/
Changeset: 4de95db7c1c4
Branch: yt
User: a_gilbert
Date: 2016-07-19 22:40:35+00:00
Summary: data_structures.py edited online with Bitbucket
Affected #: 1 file
diff -r 6e1c2aa8c6141c655bf6d0855c957a66d251415f -r 4de95db7c1c4dd853e6a5534e769977540f44303 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -668,7 +668,7 @@
sfh.update({0:data})
grid_left_edges = domain_left_edge
grid_right_edges = domain_right_edge
- grid_dimensions = domain_dimensions.reshape(nprocs, len(domain_dimensions)).astype("int32")
+ grid_dimensions = domain_dimensions.reshape(nprocs, 3).astype("int32")
if length_unit is None:
length_unit = 'code_length'
https://bitbucket.org/yt_analysis/yt/commits/f60d01f513a3/
Changeset: f60d01f513a3
Branch: yt
User: a_gilbert
Date: 2016-07-19 23:55:38+00:00
Summary: Passing figure to canvas
Affected #: 1 file
diff -r 6e1c2aa8c6141c655bf6d0855c957a66d251415f -r f60d01f513a36705a66822cedbb5fdd8f0f1511e yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -94,7 +94,7 @@
axes.set_position(axrect)
self.axes = axes
canvasClasses = PlotMPL._set_canvas()
- self.canvas = canvasClasses[0]
+ self.canvas = canvasClasses[0](self.figure)
if len(canvasClasses) > 1:
self.manager = canvasClasses[1](self.canvas, 1)
for which in ['major', 'minor']:
https://bitbucket.org/yt_analysis/yt/commits/fefde76aac21/
Changeset: fefde76aac21
Branch: yt
User: a_gilbert
Date: 2016-07-20 18:43:50+00:00
Summary: updated docs, made interactivity a global setting.
Affected #: 6 files
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf CREDITS
--- a/CREDITS
+++ b/CREDITS
@@ -21,6 +21,7 @@
Daniel Fenn (df11c at my.fsu.edu)
John Forces (jforbes at ucolick.org)
Adam Ginsburg (keflavich at gmail.com)
+ Austin Gilbert (augilbert4 at gmail.com)
Sam Geen (samgeen at gmail.com)
Nathan Goldbaum (goldbaum at ucolick.org)
William Gray (graywilliamj at gmail.com)
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -17,6 +17,22 @@
plots of slices, projections, 1D profiles, and 2D profiles (phase plots), all of
which are described below.
+.. _viewing-plots:
+
+Viewing Plots
+-------------
+
+YT uses an environment neutral plotting mechanism that detects the appropriate
+matplotlib configuration for a given environment, however it defaults to a basic
+renderer. To utilize interactive plots in matplotlib supported
+environments, simply call the ``set_interactivity()`` function. Below is an
+example in a jupyter notebook environment:
+
+.. code-block:: python
+ %matplotlib notebook
+ import yt
+ yt.set_interactivity()
+
.. _simple-inspection:
Slices & Projections
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -155,7 +155,8 @@
ProjectionPlot, OffAxisProjectionPlot, \
show_colormaps, add_cmap, make_colormap, \
ProfilePlot, PhasePlot, ParticlePhasePlot, \
- ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot
+ ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
+ set_interactivity
from yt.visualization.volume_rendering.api import \
volume_render, create_scene, ColorTransferFunction, TransferFunction, \
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -58,4 +58,5 @@
PhasePlot
from .base_plot_types import \
+ set_interactivity, \
get_multi_plot
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -44,6 +44,15 @@
'agg': ['backend_agg', 'FigureCanvasAgg']}
+"""condition that interactive backends can be used."""
+interactivity = False
+
+"""Sets the condition that interactive backends can be used."""
+def set_interactivity():
+ global interactivity
+ interactivity = not interactivity
+
+
class CallbackWrapper(object):
def __init__(self, viewer, window_plot, frb, field, font_properties,
font_color):
@@ -76,8 +85,6 @@
"""
- interactive = False
-
def __init__(self, fsize, axrect, figure, axes):
"""Initialize PlotMPL class"""
import matplotlib.figure
@@ -93,7 +100,7 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- canvasClasses = PlotMPL._set_canvas()
+ canvasClasses = self._set_canvas()
self.canvas = canvasClasses[0](self.figure)
if len(canvasClasses) > 1:
self.manager = canvasClasses[1](self.canvas, 1)
@@ -101,9 +108,9 @@
for axis in 'xy':
self.axes.tick_params(which=which, axis=axis, direction='in')
- @classmethod
- def _set_canvas(cls):
- if PlotMPL.interactive:
+ def _set_canvas(self):
+ self.interactivity = interactivity
+ if interactivity:
backend = str(matplotlib.get_backend())
else:
backend = 'agg'
@@ -120,16 +127,6 @@
else:
return [FigureCanvas]
- @classmethod
- def ion(cls):
- """Toggles interactive backends on."""
- cls.interactive = True
-
- @classmethod
- def ioff(cls):
- """Toggles interactive backends off."""
- cls.interactive = False
-
def save(self, name, mpl_kwargs=None, canvas=None):
"""Choose backend and save image to disk"""
from ._mpl_imports import \
diff -r f60d01f513a36705a66822cedbb5fdd8f0f1511e -r fefde76aac21165a3c0c2aa4ec587b1a6759accf yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -617,8 +617,18 @@
>>> slc.show()
"""
- for k,v in sorted(iteritems(self.plots)):
- v.show()
+ interactivity = self.plots[self.plots.keys()[0]].interactivity
+ if interactivity:
+ for k,v in sorted(iteritems(self.plots)):
+ v.show()
+ else:
+ if "__IPYTHON__" in dir(builtins):
+ api_version = get_ipython_api_version()
+ if api_version in ('0.10', '0.11'):
+ self._send_zmq()
+ else:
+ from IPython.display import display
+ display(self)
@validate_plot
def display(self, name=None, mpl_kwargs=None):
https://bitbucket.org/yt_analysis/yt/commits/5927f9a5e402/
Changeset: 5927f9a5e402
Branch: yt
User: a_gilbert
Date: 2016-07-20 19:15:00+00:00
Summary: merging
Affected #: 1 file
diff -r fefde76aac21165a3c0c2aa4ec587b1a6759accf -r 5927f9a5e4023ab2f9d4c63b4a052d0bc6fb19ee yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -668,7 +668,7 @@
sfh.update({0:data})
grid_left_edges = domain_left_edge
grid_right_edges = domain_right_edge
- grid_dimensions = domain_dimensions.reshape(nprocs, len(domain_dimensions)).astype("int32")
+ grid_dimensions = domain_dimensions.reshape(nprocs, 3).astype("int32")
if length_unit is None:
length_unit = 'code_length'
https://bitbucket.org/yt_analysis/yt/commits/1020680f726e/
Changeset: 1020680f726e
Branch: yt
User: a_gilbert
Date: 2016-07-20 20:42:46+00:00
Summary: Modified import statement to comply with Python 3.5
Affected #: 1 file
diff -r 5927f9a5e4023ab2f9d4c63b4a052d0bc6fb19ee -r 1020680f726e5bcdbbb06e9b51713788fb602014 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -118,7 +118,7 @@
for key in backend_dict.keys():
if key == backend:
mod = __import__('matplotlib.backends', globals(), locals(),
- [backend_dict[key][0]], -1)
+ [backend_dict[key][0]], 0)
submod = getattr(mod, backend_dict[key][0])
FigureCanvas = getattr(submod, backend_dict[key][1])
if len(backend_dict[key]) > 2:
https://bitbucket.org/yt_analysis/yt/commits/0887a7960a20/
Changeset: 0887a7960a20
Branch: yt
User: a_gilbert
Date: 2016-07-21 00:04:06+00:00
Summary: minor aesthetic changes.
Affected #: 2 files
diff -r 1020680f726e5bcdbbb06e9b51713788fb602014 -r 0887a7960a20d116d5031b30ee3524e02dafb6a4 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -26,12 +26,13 @@
matplotlib configuration for a given environment, however it defaults to a basic
renderer. To utilize interactive plots in matplotlib supported
environments, simply call the ``set_interactivity()`` function. Below is an
-example in a jupyter notebook environment:
+example in a jupyter notebook environment, but the same command should work
+in other environments as well:
.. code-block:: python
%matplotlib notebook
import yt
- yt.set_interactivity()
+ yt.toggle_interactivity()
.. _simple-inspection:
diff -r 1020680f726e5bcdbbb06e9b51713788fb602014 -r 0887a7960a20d116d5031b30ee3524e02dafb6a4 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -48,7 +48,7 @@
interactivity = False
"""Sets the condition that interactive backends can be used."""
-def set_interactivity():
+def toggle_interactivity():
global interactivity
interactivity = not interactivity
@@ -100,10 +100,10 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- canvasClasses = self._set_canvas()
- self.canvas = canvasClasses[0](self.figure)
- if len(canvasClasses) > 1:
- self.manager = canvasClasses[1](self.canvas, 1)
+ canvas_classes = self._set_canvas()
+ self.canvas = canvas_classes[0](self.figure)
+ if len(canvas_classes) > 1:
+ self.manager = canvas_classes[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
self.axes.tick_params(which=which, axis=axis, direction='in')
https://bitbucket.org/yt_analysis/yt/commits/ad69277d6ccc/
Changeset: ad69277d6ccc
Branch: yt
User: a_gilbert
Date: 2016-07-21 00:12:52+00:00
Summary: Updating for change to toggle_interactivity
Affected #: 2 files
diff -r 0887a7960a20d116d5031b30ee3524e02dafb6a4 -r ad69277d6ccc3d6af5a3154ee0887e8ee906cb14 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -156,7 +156,7 @@
show_colormaps, add_cmap, make_colormap, \
ProfilePlot, PhasePlot, ParticlePhasePlot, \
ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
- set_interactivity
+ toggle_interactivity
from yt.visualization.volume_rendering.api import \
volume_render, create_scene, ColorTransferFunction, TransferFunction, \
diff -r 0887a7960a20d116d5031b30ee3524e02dafb6a4 -r ad69277d6ccc3d6af5a3154ee0887e8ee906cb14 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -58,5 +58,5 @@
PhasePlot
from .base_plot_types import \
- set_interactivity, \
+ toggle_interactivity, \
get_multi_plot
https://bitbucket.org/yt_analysis/yt/commits/2077dfd9b48e/
Changeset: 2077dfd9b48e
Branch: yt
User: a_gilbert
Date: 2016-07-21 15:48:34+00:00
Summary: updating for python 3.5 compatibility.
Affected #: 1 file
diff -r ad69277d6ccc3d6af5a3154ee0887e8ee906cb14 -r 2077dfd9b48e9debe4fac78a2786d7d9e00f9298 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -617,7 +617,7 @@
>>> slc.show()
"""
- interactivity = self.plots[self.plots.keys()[0]].interactivity
+ interactivity = self.plots[list(self.plots.keys())[0]].interactivity
if interactivity:
for k,v in sorted(iteritems(self.plots)):
v.show()
https://bitbucket.org/yt_analysis/yt/commits/898f890c14c0/
Changeset: 898f890c14c0
Branch: yt
User: a_gilbert
Date: 2016-07-26 18:34:00+00:00
Summary: taking care of documentation
Affected #: 1 file
diff -r 2077dfd9b48e9debe4fac78a2786d7d9e00f9298 -r 898f890c14c08b04d9814d73ebff14de3c5ed256 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -25,11 +25,12 @@
YT uses an environment neutral plotting mechanism that detects the appropriate
matplotlib configuration for a given environment, however it defaults to a basic
renderer. To utilize interactive plots in matplotlib supported
-environments, simply call the ``set_interactivity()`` function. Below is an
+environments (Qt, GTK, WX, etc.) simply call the ``toggle_interactivity()`` function. Below is an
example in a jupyter notebook environment, but the same command should work
in other environments as well:
.. code-block:: python
+
%matplotlib notebook
import yt
yt.toggle_interactivity()
https://bitbucket.org/yt_analysis/yt/commits/7ecf76211973/
Changeset: 7ecf76211973
Branch: yt
User: ngoldbaum
Date: 2016-08-01 18:13:41+00:00
Summary: Do a bit more to set up the interactive environment
Affected #: 4 files
diff -r 898f890c14c08b04d9814d73ebff14de3c5ed256 -r 7ecf762119730bd6b338824b32c0664381ea4cc8 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -93,7 +93,8 @@
parallel_profile, \
enable_plugins, \
memory_checker, \
- deprecated_class
+ deprecated_class, \
+ toggle_interactivity
from yt.utilities.logger import ytLogger as mylog
import yt.utilities.physical_constants as physical_constants
@@ -155,8 +156,7 @@
ProjectionPlot, OffAxisProjectionPlot, \
show_colormaps, add_cmap, make_colormap, \
ProfilePlot, PhasePlot, ParticlePhasePlot, \
- ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
- toggle_interactivity
+ ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot
from yt.visualization.volume_rendering.api import \
volume_render, create_scene, ColorTransferFunction, TransferFunction, \
diff -r 898f890c14c08b04d9814d73ebff14de3c5ed256 -r 7ecf762119730bd6b338824b32c0664381ea4cc8 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -16,7 +16,7 @@
import errno
from yt.extern.six import string_types
-from yt.extern.six.moves import input
+from yt.extern.six.moves import input, builtins
import time
import inspect
import traceback
@@ -987,3 +987,20 @@
pass
return dummy_context_manager()
+interactivity = False
+
+"""Sets the condition that interactive backends can be used."""
+def toggle_interactivity():
+ global interactivity
+ interactivity = not interactivity
+ if interactivity is True:
+ if '__IPYTHON__' in dir(builtins):
+ import IPython
+ shell = IPython.get_ipython()
+ shell.magic('matplotlib')
+ else:
+ import matplotlib
+ matplotlib.interactive(True)
+
+def get_interactivity():
+ return interactivity
diff -r 898f890c14c08b04d9814d73ebff14de3c5ed256 -r 7ecf762119730bd6b338824b32c0664381ea4cc8 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -58,5 +58,4 @@
PhasePlot
from .base_plot_types import \
- toggle_interactivity, \
get_multi_plot
diff -r 898f890c14c08b04d9814d73ebff14de3c5ed256 -r 7ecf762119730bd6b338824b32c0664381ea4cc8 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -20,7 +20,8 @@
mylog, \
iterable, \
get_brewer_cmap, \
- matplotlib_style_context
+ matplotlib_style_context, \
+ get_interactivity
import numpy as np
backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
@@ -44,15 +45,6 @@
'agg': ['backend_agg', 'FigureCanvasAgg']}
-"""condition that interactive backends can be used."""
-interactivity = False
-
-"""Sets the condition that interactive backends can be used."""
-def toggle_interactivity():
- global interactivity
- interactivity = not interactivity
-
-
class CallbackWrapper(object):
def __init__(self, viewer, window_plot, frb, field, font_properties,
font_color):
@@ -109,8 +101,8 @@
self.axes.tick_params(which=which, axis=axis, direction='in')
def _set_canvas(self):
- self.interactivity = interactivity
- if interactivity:
+ self.interactivity = get_interactivity()
+ if self.interactivity:
backend = str(matplotlib.get_backend())
else:
backend = 'agg'
https://bitbucket.org/yt_analysis/yt/commits/6f6559da7679/
Changeset: 6f6559da7679
Branch: yt
User: a_gilbert
Date: 2016-08-01 20:32:57+00:00
Summary: Fixing documentation issues
Affected #: 1 file
diff -r 7ecf762119730bd6b338824b32c0664381ea4cc8 -r 6f6559da767901ee3c2aa646fc5cd5b28065b7f7 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -145,8 +145,7 @@
Parameters
----------
- data_source : :class:`yt.data_objects.construction_data_containers.YTQuadTreeProj`
- or :class:`yt.data_objects.selection_data_containers.YTSlice`
+ data_source : :class:`yt.data_objects.construction_data_containers.YTQuadTreeProj` or :class:`yt.data_objects.selection_data_containers.YTSlice`
This is the source to be pixelized, which can be a projection or a
slice. (For cutting planes, see
`yt.visualization.fixed_resolution.ObliqueFixedResolutionBuffer`.)
https://bitbucket.org/yt_analysis/yt/commits/fb82173a3279/
Changeset: fb82173a3279
Branch: yt
User: jzuhone
Date: 2016-08-03 14:06:25+00:00
Summary: Merged in a_gilbert/yt (pull request #2294)
Backend Independent Plots: Closing Issue #660
Affected #: 11 files
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f CREDITS
--- a/CREDITS
+++ b/CREDITS
@@ -21,6 +21,7 @@
Daniel Fenn (df11c at my.fsu.edu)
John Forces (jforbes at ucolick.org)
Adam Ginsburg (keflavich at gmail.com)
+ Austin Gilbert (augilbert4 at gmail.com)
Sam Geen (samgeen at gmail.com)
Nathan Goldbaum (goldbaum at ucolick.org)
William Gray (graywilliamj at gmail.com)
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -17,6 +17,24 @@
plots of slices, projections, 1D profiles, and 2D profiles (phase plots), all of
which are described below.
+.. _viewing-plots:
+
+Viewing Plots
+-------------
+
+YT uses an environment neutral plotting mechanism that detects the appropriate
+matplotlib configuration for a given environment, however it defaults to a basic
+renderer. To utilize interactive plots in matplotlib supported
+environments (Qt, GTK, WX, etc.) simply call the ``toggle_interactivity()`` function. Below is an
+example in a jupyter notebook environment, but the same command should work
+in other environments as well:
+
+.. code-block:: python
+
+ %matplotlib notebook
+ import yt
+ yt.toggle_interactivity()
+
.. _simple-inspection:
Slices & Projections
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -93,7 +93,8 @@
parallel_profile, \
enable_plugins, \
memory_checker, \
- deprecated_class
+ deprecated_class, \
+ toggle_interactivity
from yt.utilities.logger import ytLogger as mylog
import yt.utilities.physical_constants as physical_constants
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/analysis_modules/level_sets/clump_handling.py
--- a/yt/analysis_modules/level_sets/clump_handling.py
+++ b/yt/analysis_modules/level_sets/clump_handling.py
@@ -85,7 +85,7 @@
if self.children is None: return
for child in self.children:
child.add_validator(validator)
-
+
def add_info_item(self, info_item, *args, **kwargs):
"Adds an entry to clump_info list and tells children to do the same."
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/convenience.py
--- a/yt/convenience.py
+++ b/yt/convenience.py
@@ -127,4 +127,3 @@
return simulation_time_series_registry[simulation_type](parameter_filename,
find_outputs=find_outputs)
-
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -668,7 +668,7 @@
sfh.update({0:data})
grid_left_edges = domain_left_edge
grid_right_edges = domain_right_edge
- grid_dimensions = domain_dimensions.reshape(nprocs,3).astype("int32")
+ grid_dimensions = domain_dimensions.reshape(nprocs, 3).astype("int32")
if length_unit is None:
length_unit = 'code_length'
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -16,7 +16,7 @@
import errno
from yt.extern.six import string_types
-from yt.extern.six.moves import input
+from yt.extern.six.moves import input, builtins
import time
import inspect
import traceback
@@ -986,3 +986,21 @@
except ImportError:
pass
return dummy_context_manager()
+
+interactivity = False
+
+"""Sets the condition that interactive backends can be used."""
+def toggle_interactivity():
+ global interactivity
+ interactivity = not interactivity
+ if interactivity is True:
+ if '__IPYTHON__' in dir(builtins):
+ import IPython
+ shell = IPython.get_ipython()
+ shell.magic('matplotlib')
+ else:
+ import matplotlib
+ matplotlib.interactive(True)
+
+def get_interactivity():
+ return interactivity
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -20,9 +20,30 @@
mylog, \
iterable, \
get_brewer_cmap, \
- matplotlib_style_context
+ matplotlib_style_context, \
+ get_interactivity
import numpy as np
+backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
+ 'FigureManagerGTK'],
+ 'GTKAgg': ['backend_gtkagg', 'FigureCanvasGTKAgg'],
+ 'GTKCairo': ['backend_gtkcairo', 'FigureCanvasGTKCairo'],
+ 'MacOSX': ['backend_macosx', 'FigureCanvasMac', 'FigureManagerMac'],
+ 'Qt4Agg': ['backend_qt4agg', 'FigureCanvasQTAgg'],
+ 'Qt5Agg': ['backend_gt5agg', 'FigureCanvasQTAgg'],
+ 'TkAgg': ['backend_tkagg', 'FigureCanvasTkAgg'],
+ 'WX': ['backend_wx', 'FigureCanvasWx'],
+ 'WXAgg': ['backend_wxagg', 'FigureCanvasWxAgg'],
+ 'GTK3Cairo': ['backend_gtk3cairo',
+ 'FigureCanvasGTK3Cairo',
+ 'FigureManagerGTK3Cairo'],
+ 'GTK3Agg': ['backend_gtk3agg', 'FigureCanvasGTK3Agg',
+ 'FigureManagerGTK3Agg'],
+ 'WebAgg': ['backend_webagg', 'FigureCanvasWebAgg'],
+ 'nbAgg': ['backend_nbagg', 'FigureCanvasNbAgg',
+ 'FigureManagerNbAgg'],
+ 'agg': ['backend_agg', 'FigureCanvasAgg']}
+
class CallbackWrapper(object):
def __init__(self, viewer, window_plot, frb, field, font_properties,
@@ -50,14 +71,15 @@
self.font_color = font_color
self.field = field
+
class PlotMPL(object):
- """A base class for all yt plots made using matplotlib.
+ """A base class for all yt plots made using matplotlib, that is backend independent.
"""
+
def __init__(self, fsize, axrect, figure, axes):
"""Initialize PlotMPL class"""
import matplotlib.figure
- from ._mpl_imports import FigureCanvasAgg
self._plot_valid = True
if figure is None:
self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
@@ -70,11 +92,33 @@
axes.cla()
axes.set_position(axrect)
self.axes = axes
- self.canvas = FigureCanvasAgg(self.figure)
+ canvas_classes = self._set_canvas()
+ self.canvas = canvas_classes[0](self.figure)
+ if len(canvas_classes) > 1:
+ self.manager = canvas_classes[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
self.axes.tick_params(which=which, axis=axis, direction='in')
+ def _set_canvas(self):
+ self.interactivity = get_interactivity()
+ if self.interactivity:
+ backend = str(matplotlib.get_backend())
+ else:
+ backend = 'agg'
+
+ for key in backend_dict.keys():
+ if key == backend:
+ mod = __import__('matplotlib.backends', globals(), locals(),
+ [backend_dict[key][0]], 0)
+ submod = getattr(mod, backend_dict[key][0])
+ FigureCanvas = getattr(submod, backend_dict[key][1])
+ if len(backend_dict[key]) > 2:
+ FigureManager = getattr(submod, backend_dict[key][2])
+ return [FigureCanvas, FigureManager]
+ else:
+ return [FigureCanvas]
+
def save(self, name, mpl_kwargs=None, canvas=None):
"""Choose backend and save image to disk"""
from ._mpl_imports import \
@@ -105,6 +149,12 @@
canvas.print_figure(name, **mpl_kwargs)
return name
+ def show(self):
+ try:
+ self.manager.show()
+ except AttributeError:
+ self.canvas.show()
+
def _get_labels(self):
ax = self.axes
labels = ax.xaxis.get_ticklabels() + ax.yaxis.get_ticklabels()
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -620,15 +620,18 @@
>>> slc.show()
"""
- if "__IPYTHON__" in dir(builtins):
- api_version = get_ipython_api_version()
- if api_version in ('0.10', '0.11'):
- self._send_zmq()
- else:
- from IPython.display import display
- display(self)
+ interactivity = self.plots[list(self.plots.keys())[0]].interactivity
+ if interactivity:
+ for k,v in sorted(iteritems(self.plots)):
+ v.show()
else:
- raise YTNotInsideNotebook
+ if "__IPYTHON__" in dir(builtins):
+ api_version = get_ipython_api_version()
+ if api_version in ('0.10', '0.11'):
+ self._send_zmq()
+ else:
+ from IPython.display import display
+ display(self)
@validate_plot
def display(self, name=None, mpl_kwargs=None):
diff -r 517b33cc1b1f11456721183f80aa4669d8f80da8 -r fb82173a327964238da127db05ea1af176616f8f yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -23,7 +23,8 @@
from distutils.version import LooseVersion
from numbers import Number
-from .base_plot_types import ImagePlotMPL
+from .base_plot_types import \
+ ImagePlotMPL
from .fixed_resolution import \
FixedResolutionBuffer, \
ObliqueFixedResolutionBuffer, \
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list