source: sasview/plottools/src/danse/common/plottools/config.py @ 82a54b8

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 82a54b8 was 82a54b8, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

adding plottools Part 2

  • Property mode set to 100644
File size: 1.9 KB
Line 
1# This program is public domain
2"""
3Configure plotter for plottools.
4
5This must be imported first in __init__.py for plottools.
6
7If your application uses matplotlib outside plottools, then
8please do the following at the start of your application:
9
10    # Select matplotlib version and backend
11    import danse.common.plottools.config
12
13Note that plottools requires particular versions of matplotlib
14and a particular backend.  As of this writing it is the WXAgg
15backend for matplotlib>=0.98.
16
17The plottools package uses pkg_resources if available to select
18the correct version of matplotlib.  If you need multiple matplotlib
19versions in your path, be sure to use "easy_install -m" for all
20of them.  If a version is installed without "-m" that does not
21meet the requirements, then pkg_resources.require() will fail,
22even if you have installed a suitable version with "-m".  In this
23case you will need to fix up your site-packages directory,
24probably by removing site-packages/matplotlib and the associated
25egg file for that version, and reinstalling with "-m".  You may
26also need to edit site-packages/easy-install.pth.
27"""
28import sys
29
30__all__ = []
31
32plot_version = "0.98"
33plot_backend = "WXAgg"
34
35# Sort out matplotlib version
36try:
37    import matplotlib
38    import pkg_resources
39    pkg_resources.require("matplotlib>=" + plot_version)
40except:
41    #import matplotlib
42    from distutils.version import LooseVersion as Version
43    if Version(matplotlib.__version__) < Version(plot_version):
44        msg = "Matplotlib version must be %s or newer" % (plot_version, )
45        raise ImportError(msg)
46
47# Sort out matplotlib backend
48#import matplotlib
49if 'matplotlib.backends' not in sys.modules:
50    # if no backend yet, be sure to use the correct one
51    matplotlib.use(plot_backend)
52elif matplotlib.get_backend() != plot_backend:
53    # if a backend has already been selected, make sure it is the correct one.
54    raise ImportError("Matplotlib not using backend " + plot_backend)
55
Note: See TracBrowser for help on using the repository browser.