source: sasview/src/sas/sasgui/plottools/config.py

ESS_GUI
Last change on this file was 4992ff2, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Initial, in-progress version. Not really working atm. SASVIEW-787

  • Property mode set to 100644
File size: 2.5 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 sas.sasgui.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
32#plot_version = "0.98"
33#plot_backend = "WXAgg"
34print("SET MPL BACKEND TO Qt5")
35plot_backend = "Qt5Agg"
36
37# Sort out matplotlib version
38import matplotlib
39#try:
40#    import pkg_resources
41#    pkg_resources.require("matplotlib>=" + plot_version)
42#except:
43#    from distutils.version import LooseVersion as Version
44#    if Version(matplotlib.__version__) < Version(plot_version):
45#        msg = "Matplotlib version must be %s or newer" % (plot_version, )
46#        raise ImportError(msg)
47
48# Sort out matplotlib backend
49#import matplotlib
50if 'matplotlib.backends' not in sys.modules:
51    # if no backend yet, be sure to use the correct one
52    matplotlib.use(plot_backend)
53elif matplotlib.get_backend() != plot_backend:
54    # if a backend has already been selected, make sure it is the correct one.
55    #raise ImportError("Matplotlib not using backend " + plot_backend)
56    pass
57
58# set global plot style
59param = 'legend.handletextpad'
60if param not in matplotlib.rcParams: param = 'legend.handletextsep'
61matplotlib.rcParams[param] = 0.05
62matplotlib.rcParams['legend.numpoints'] = 1
63#matplotlib.rcParams['interactive'] = True
64
65
66# this should happen after initial matplotlib configuration
67#from .toolbar import NavigationToolBar
68#from matplotlib.backends import backend_wxagg
69#backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar
70
71# CRUFT: bumps 0.7.5.6 and older uses wrong toolbar
72#backend_wxagg.NavigationToolbar2Wx = NavigationToolBar
Note: See TracBrowser for help on using the repository browser.