Python matplotlib.__version__() Examples
The following are 30
code examples of matplotlib.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: figure.py From Computable with MIT License | 6 votes |
def __getstate__(self): state = self.__dict__.copy() # the axobservers cannot currently be pickled. # Additionally, the canvas cannot currently be pickled, but this has # the benefit of meaning that a figure can be detached from one canvas, # and re-attached to another. for attr_to_pop in ('_axobservers', 'show', 'canvas', '_cachedRenderer'): state.pop(attr_to_pop, None) # add version information to the state state['__mpl_version__'] = _mpl_version # check to see if the figure has a manager and whether it is registered # with pyplot if getattr(self.canvas, 'manager', None) is not None: manager = self.canvas.manager import matplotlib._pylab_helpers if manager in matplotlib._pylab_helpers.Gcf.figs.values(): state['_restore_to_pylab'] = True return state
Example #2
Source File: matplotlib.py From pmdarima with MIT License | 6 votes |
def mpl_hist_arg(value=True): """Find the appropriate `density` kwarg for our given matplotlib version. This will determine if we should use `normed` or `density`. Additionally, since this is a kwarg, the user can supply a value (True or False) that they would like in the output dictionary. Parameters ---------- value : bool, optional (default=True) The boolean value of density/normed Returns ------- density_kwarg : dict A dictionary containing the appropriate density kwarg for the installed matplotlib version, mapped to the provided or default value """ import matplotlib density_kwarg = 'density' if matplotlib.__version__ >= '2.1.0'\ else 'normed' return {density_kwarg: value}
Example #3
Source File: figure.py From matplotlib-4-abaqus with MIT License | 6 votes |
def __getstate__(self): state = self.__dict__.copy() # the axobservers cannot currently be pickled. # Additionally, the canvas cannot currently be pickled, but this has # the benefit of meaning that a figure can be detached from one canvas, # and re-attached to another. for attr_to_pop in ('_axobservers', 'show', 'canvas', '_cachedRenderer'): state.pop(attr_to_pop, None) # add version information to the state state['__mpl_version__'] = _mpl_version # check to see if the figure has a manager and whether it is registered # with pyplot if getattr(self.canvas, 'manager', None) is not None: manager = self.canvas.manager import matplotlib._pylab_helpers if manager in matplotlib._pylab_helpers.Gcf.figs.values(): state['_restore_to_pylab'] = True return state
Example #4
Source File: graphs.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_legend_patch(self, legend_rows, fontsize=None): if matplotlib.__version__ == '3.0.2': self.logger.warning('skipping legend patch with matplotlib v3.0.2 for compatibility') return if self._legend is not None: self._legend.remove() self._legend = None fontsize = fontsize or self.fontsize_scale legend_bbox = self.figure.legend( tuple(patches.Patch(color=patch_color) for patch_color, _ in legend_rows), tuple(label for _, label in legend_rows), borderaxespad=1.25, fontsize=fontsize, frameon=True, handlelength=1.5, handletextpad=0.75, labelspacing=0.3, loc='lower right' ) legend_bbox.legendPatch.set_linewidth(0) self._legend = legend_bbox
Example #5
Source File: graphs.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add_legend_patch(self, legend_rows, fontsize=None): if matplotlib.__version__ == '3.0.2': self.logger.warning('skipping legend patch with matplotlib v3.0.2 for compatibility') return if self._legend is not None: self._legend.remove() self._legend = None legend_bbox = self.figure.legend( tuple(lines.Line2D([], [], color=patch_color, lw=3, ls=style) for patch_color, style, _ in legend_rows), tuple(label for _, _, label in legend_rows), borderaxespad=1, columnspacing=1.5, fontsize=self.fontsize_scale, ncol=3, frameon=True, handlelength=2, handletextpad=0.5, labelspacing=0.5, loc='upper right' ) legend_bbox.get_frame().set_facecolor(self.get_color('line_bg', ColorHexCode.GRAY)) for text in legend_bbox.get_texts(): text.set_color('white') legend_bbox.legendPatch.set_linewidth(0) self._legend = legend_bbox
Example #6
Source File: figure.py From neural-network-animation with MIT License | 6 votes |
def __getstate__(self): state = self.__dict__.copy() # the axobservers cannot currently be pickled. # Additionally, the canvas cannot currently be pickled, but this has # the benefit of meaning that a figure can be detached from one canvas, # and re-attached to another. for attr_to_pop in ('_axobservers', 'show', 'canvas', '_cachedRenderer'): state.pop(attr_to_pop, None) # add version information to the state state['__mpl_version__'] = _mpl_version # check to see if the figure has a manager and whether it is registered # with pyplot if getattr(self.canvas, 'manager', None) is not None: manager = self.canvas.manager import matplotlib._pylab_helpers if manager in list(six.itervalues( matplotlib._pylab_helpers.Gcf.figs)): state['_restore_to_pylab'] = True return state
Example #7
Source File: base.py From mplexporter with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _iter_path_collection(paths, path_transforms, offsets, styles): """Build an iterator over the elements of the path collection""" N = max(len(paths), len(offsets)) # Before mpl 1.4.0, path_transform can be a false-y value, not a valid # transformation matrix. if LooseVersion(mpl.__version__) < LooseVersion('1.4.0'): if path_transforms is None: path_transforms = [np.eye(3)] edgecolor = styles['edgecolor'] if np.size(edgecolor) == 0: edgecolor = ['none'] facecolor = styles['facecolor'] if np.size(facecolor) == 0: facecolor = ['none'] elements = [paths, path_transforms, offsets, edgecolor, styles['linewidth'], facecolor] it = itertools return it.islice(py3k.zip(*py3k.map(it.cycle, elements)), N)
Example #8
Source File: test_basic.py From mplexporter with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_image(): # Test fails for matplotlib 1.5+ because the size of the image # generated by matplotlib has changed. if LooseVersion(matplotlib.__version__) >= LooseVersion('1.5.0'): raise SkipTest("Test fails for matplotlib version > 1.5.0"); np.random.seed(0) # image size depends on the seed fig, ax = plt.subplots(figsize=(2, 2)) ax.imshow(np.random.random((10, 10)), cmap=plt.cm.jet, interpolation='nearest') _assert_output_equal(fake_renderer_output(fig, FakeRenderer), """ opening figure opening axes draw image of size 1240 closing axes closing figure """)
Example #9
Source File: __init__.py From psyplot with GNU General Public License v2.0 | 5 votes |
def _get_versions(requirements=True): if requirements: import matplotlib as mpl import xarray as xr import pandas as pd import numpy as np return {'version': __version__, 'requirements': {'matplotlib': mpl.__version__, 'xarray': xr.__version__, 'pandas': pd.__version__, 'numpy': np.__version__, 'python': ' '.join(sys.version.splitlines())}} else: return {'version': __version__}
Example #10
Source File: _on_demand_imports.py From unyt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __version__(self): if self._version is None: try: import astropy version = astropy.__version__ except ImportError: version = NotAModule(self._name) self._version = version return self._version
Example #11
Source File: mpl_plotter.py From scikit-hep with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _checks_and_wrangling(self, x, w): # Manage the input data in the same fashion as mpl if np.isscalar(x): x = [x] input_empty = (np.size(x) == 0) # Massage 'x' for processing. if input_empty: x = np.array([[]]) elif mpl.__version__ < '2.1.0': x = cbook._reshape_2D(x) else: x = cbook._reshape_2D(x, 'x') self.n_data_sets = len(x) # number of datasets # We need to do to 'weights' what was done to 'x' if w is not None: if mpl.__version__ < '2.1.0': w = cbook._reshape_2D(w) else: w = cbook._reshape_2D(w, 'w') if w is not None and len(w) != self.n_data_sets: raise ValueError('weights should have the same shape as x') if w is not None: for xi, wi in zip(x, w): if wi is not None and len(wi) != len(xi): raise ValueError('weights should have the same shape as x') return x, w
Example #12
Source File: _compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _mpl_ge_2_0_0(): try: import matplotlib return matplotlib.__version__ >= LooseVersion('2.0') except ImportError: return False
Example #13
Source File: _compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _mpl_ge_1_5_0(): try: import matplotlib return (matplotlib.__version__ >= LooseVersion('1.5') or matplotlib.__version__[0] == '0') except ImportError: return False
Example #14
Source File: _compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _mpl_ge_1_4_0(): try: import matplotlib return (matplotlib.__version__ >= LooseVersion('1.4') or matplotlib.__version__[0] == '0') except ImportError: return False
Example #15
Source File: _compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _mpl_ge_1_3_1(): try: import matplotlib # The or v[0] == '0' is because their versioneer is # messed up on dev return (matplotlib.__version__ >= LooseVersion('1.3.1') or matplotlib.__version__[0] == '0') except ImportError: return False
Example #16
Source File: _compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _mpl_le_1_2_1(): try: import matplotlib as mpl return (str(mpl.__version__) <= LooseVersion('1.2.1') and str(mpl.__version__)[0] != '0') except ImportError: return False
Example #17
Source File: projectcreator.py From READemption with ISC License | 5 votes |
def create_version_file(self, version_file_path, version): with open(version_file_path, "w") as fh: fh.write("READemption version: %s\n" % version) fh.write("Python version: %s\n" % sys.version.replace("\n", " ")) fh.write("Biopython version: %s\n" % Bio.__version__) fh.write("pysam version: %s\n" % pysam.__version__) fh.write("matplotlib version: %s\n" % matplotlib.__version__) fh.write("pandas version: %s\n" % pd.__version__)
Example #18
Source File: test_plot.py From scprep with GNU General Public License v3.0 | 5 votes |
def test_generate_colorbar_dict(): if Version(matplotlib.__version__) >= Version("3.2"): errtype = ValueError msg = "is not a valid value for name; supported values are" else: errtype = TypeError msg = "unhashable type: 'dict'" utils.assert_raises_message( errtype, msg, scprep.plot.tools.generate_colorbar, cmap={"+": "r", "-": "b"}, )
Example #19
Source File: conf.py From oggm with BSD 3-Clause "New" or "Revised" License | 5 votes |
def write_index(): """This is to write the docs for the index automatically.""" here = os.path.dirname(__file__) filename = os.path.join(here, '_generated', 'version_text.txt') try: os.makedirs(os.path.dirname(filename)) except FileExistsError: pass text = text_version if '+' not in oggm.__version__ else text_dev with open(filename, 'w') as f: f.write(text)
Example #20
Source File: _on_demand_imports.py From unyt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __version__(self): if self._version is None: try: from matplotlib import __version__ self._version = __version__ except ImportError: self._version = NotAModule(self._name) return self._version
Example #21
Source File: _on_demand_imports.py From unyt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __version__(self): if self._version is None: try: from h5py import __version__ self._version = __version__ except ImportError: self._version = NotAModule(self._name) return self._version
Example #22
Source File: testing.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _skip_if_mpl_1_5(): import matplotlib as mpl v = mpl.__version__ if v > LooseVersion('1.4.3') or v[0] == '0': import pytest pytest.skip("matplotlib 1.5") else: mpl.use("Agg", warn=False)
Example #23
Source File: elecsus_gui.py From ElecSus with Apache License 2.0 | 5 votes |
def __init__(self, parent, mainwin, ID): """ mainwin is the main panel so we can bind buttons to actions in the main frame """ wx.Panel.__init__(self, parent, id=-1) self.fig = plt.figure(ID,facecolor=(240./255,240./255,240./255),figsize=(12.9,9.75),dpi=80) #self.ax = self.fig.add_subplot(111) # create the wx objects to hold the figure self.canvas = FigureCanvasWxAgg(self, -1, self.fig) self.toolbar = Toolbar(self.canvas) #matplotlib toolbar (pan, zoom, save etc) #self.toolbar.Realize() # Create vertical sizer to hold figure and toolbar - dynamically expand with window size plot_sizer = wx.BoxSizer(wx.VERTICAL) plot_sizer.Add(self.canvas, 1, flag = wx.EXPAND|wx.ALL) #wx.TOP|wx.LEFT|wx.GROW) plot_sizer.Add(self.toolbar, 0, wx.EXPAND) mainwin.figs.append(self.fig) mainwin.fig_IDs.append(ID) # use an ID number to keep track of figures mainwin.canvases.append(self.canvas) # display some text in the middle of the window to begin with self.fig.text(0.5,0.5,'ElecSus GUI\n\nVersion '+__version__+'\n\nTo get started, use the panel on the right\nto either Compute a spectrum or Import some data...', ha='center',va='center') #self.fig.hold(False) self.SetSizer(plot_sizer) #self.Layout() #Fit()
Example #24
Source File: elecsus_gui.py From ElecSus with Apache License 2.0 | 5 votes |
def show_versions(): """ Shows installed version numbers """ print('Packages required for GUI: (this displays currently installed version numbers)') print('\tElecSus: ', __version__) print('\tWxPython: ', wx.__version__) print('\tNumpy: ', np.__version__) print('\tMatplotlib: ', mpl.__version__) print('Required for fitting (in addition to above):') print('\tScipy: ', sp.__version__) print('\tPSUtil: ', psutil.__version__) print('\tLMfit: ', lm.__version__)
Example #25
Source File: _compat.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def _mpl_version(version, op): def inner(): try: import matplotlib as mpl except ImportError: return False return (op(LooseVersion(mpl.__version__), LooseVersion(version)) and str(mpl.__version__)[0] != '0') return inner
Example #26
Source File: plotting.py From beat with GNU General Public License v3.0 | 5 votes |
def get_matplotlib_version(): from matplotlib import __version__ as mplversion return float(mplversion[0]), float(mplversion[2:])
Example #27
Source File: navigation_toolbar.py From RF-Monitor with GNU General Public License v2.0 | 5 votes |
def __init__(self, canvas, legend): NavigationToolbar2Wx.__init__(self, canvas) self._canvas = canvas self._legend = legend self._autoScale = True if matplotlib.__version__ >= '1.2': panId = self.wx_ids['Pan'] else: panId = self.FindById(self._NTB2_PAN).GetId() self.ToggleTool(panId, True) self.pan() checkLegend = wx.CheckBox(self, label='Legend') checkLegend.SetValue(legend.get_visible()) self.AddControl(checkLegend) self.Bind(wx.EVT_CHECKBOX, self.__on_legend, checkLegend, id) if wx.__version__ >= '2.9.1': self.AddStretchableSpace() else: self.AddSeparator() self._textCursor = wx.StaticText(self, style=wx.ALL | wx.ALIGN_RIGHT) font = self._textCursor.GetFont() if wx.__version__ >= '2.9.1': font.MakeSmaller() font.SetFamily(wx.FONTFAMILY_TELETYPE) self._textCursor.SetFont(font) w, _h = get_text_size(' ' * 18, font) self._textCursor.SetSize((w, -1)) self.AddControl(self._textCursor) self.Realize()
Example #28
Source File: figure.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __getstate__(self): state = super().__getstate__() # the axobservers cannot currently be pickled. # Additionally, the canvas cannot currently be pickled, but this has # the benefit of meaning that a figure can be detached from one canvas, # and re-attached to another. for attr_to_pop in ('_axobservers', 'show', 'canvas', '_cachedRenderer'): state.pop(attr_to_pop, None) # add version information to the state state['__mpl_version__'] = _mpl_version # check whether the figure manager (if any) is registered with pyplot from matplotlib import _pylab_helpers if getattr(self.canvas, 'manager', None) \ in _pylab_helpers.Gcf.figs.values(): state['_restore_to_pylab'] = True # set all the layoutbox information to None. kiwisolver objects can't # be pickled, so we lose the layout options at this point. state.pop('_layoutbox', None) # suptitle: if self._suptitle is not None: self._suptitle._layoutbox = None return state
Example #29
Source File: testing.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _skip_if_no_xarray(): import pytest xarray = pytest.importorskip("xarray") v = xarray.__version__ if v < LooseVersion('0.7.0'): import pytest pytest.skip("xarray version is too low: {version}".format(version=v))
Example #30
Source File: _compat.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def _mpl_le_1_2_1(): try: import matplotlib as mpl return (str(mpl.__version__) <= LooseVersion('1.2.1') and str(mpl.__version__)[0] != '0') except ImportError: return False