report_quality to init_backend.
This commit is contained in:
parent
38d1cfe435
commit
31243bcc6f
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from .config import report_quality
|
from .config import init_backend
|
||||||
from .report_tools import *
|
|
||||||
from lasp.lasp_common import FreqWeighting, TimeWeighting
|
from lasp.lasp_common import FreqWeighting, TimeWeighting
|
||||||
__all__ = ['report_quality', 'PSPlot', 'LevelBars', 'Levels', 'close',
|
__all__ = ['init_backend',
|
||||||
'FreqWeighting', 'TimeWeighting']
|
'FreqWeighting', 'TimeWeighting']
|
||||||
|
@ -5,40 +5,40 @@ Author: J.A. de Jong - ASCEE
|
|||||||
|
|
||||||
Description:
|
Description:
|
||||||
"""
|
"""
|
||||||
__all__ = ['report_quality', 'getReportQuality']
|
__all__ = ['init_backend', 'getReportQuality']
|
||||||
|
|
||||||
_report_quality = False
|
_report_quality = False
|
||||||
|
_init = False
|
||||||
|
|
||||||
|
|
||||||
|
def init_backend(report_quality=False):
|
||||||
|
global _init
|
||||||
|
if not _init:
|
||||||
|
print('Initializing matplotlib...')
|
||||||
|
_init = True
|
||||||
|
import matplotlib
|
||||||
|
matplotlib.use('Qt5Agg')
|
||||||
|
preamble = [
|
||||||
|
r'\usepackage{libertine-type1}'
|
||||||
|
r'\usepackage[libertine]{newtxmath}'
|
||||||
|
# r'\usepackage{fontspec}',
|
||||||
|
# r'\setmainfont{Libertine}',
|
||||||
|
]
|
||||||
|
params = {
|
||||||
|
'font.family': 'serif',
|
||||||
|
'text.usetex': True,
|
||||||
|
'text.latex.unicode': True,
|
||||||
|
'pgf.rcfonts': False,
|
||||||
|
'pgf.texsystem': 'pdflatex',
|
||||||
|
'pgf.preamble': preamble,
|
||||||
|
}
|
||||||
|
matplotlib.rcParams.update(params)
|
||||||
|
global _report_quality
|
||||||
|
_report_quality = report_quality
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
plt.ion()
|
||||||
|
|
||||||
|
|
||||||
def getReportQuality():
|
def getReportQuality():
|
||||||
global _report_quality
|
global _report_quality
|
||||||
return _report_quality
|
return _report_quality
|
||||||
|
|
||||||
|
|
||||||
def report_quality():
|
|
||||||
import matplotlib as mpl
|
|
||||||
# mpl.use('Qt5Agg')
|
|
||||||
global _report_quality
|
|
||||||
# mpl.use("pgf")
|
|
||||||
# rc('font',**{'family':'serif','serif':['Libertine']})
|
|
||||||
# for Palatino and other serif fonts use:
|
|
||||||
# rc('font',**{'family':'serif','serif':['Palatino']})
|
|
||||||
# rc('text', usetex=True)
|
|
||||||
# TeX preamble
|
|
||||||
preamble = [
|
|
||||||
r'\usepackage{libertine-type1}'
|
|
||||||
r'\usepackage[libertine]{newtxmath}'
|
|
||||||
# r'\usepackage{fontspec}',
|
|
||||||
# r'\setmainfont{Libertine}',
|
|
||||||
]
|
|
||||||
params = {
|
|
||||||
'font.family': 'serif',
|
|
||||||
'text.usetex': True,
|
|
||||||
'text.latex.unicode': True,
|
|
||||||
'pgf.rcfonts': False,
|
|
||||||
'pgf.texsystem': 'pdflatex',
|
|
||||||
'pgf.preamble': preamble,
|
|
||||||
}
|
|
||||||
mpl.rcParams.update(params)
|
|
||||||
|
|
||||||
_report_quality = True
|
|
||||||
|
@ -15,9 +15,6 @@ from lasp.lasp_common import (PLOT_COLORS_LIST, PLOT_NOCOLORS_LIST,
|
|||||||
DEFAULT_FIGSIZE_H, DEFAULT_FIGSIZE_W)
|
DEFAULT_FIGSIZE_H, DEFAULT_FIGSIZE_W)
|
||||||
|
|
||||||
|
|
||||||
def close():
|
|
||||||
plt.close('all')
|
|
||||||
|
|
||||||
|
|
||||||
class Figure:
|
class Figure:
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@ -43,7 +40,8 @@ class Figure:
|
|||||||
|
|
||||||
linewidths = cycler(linewidth=[1, 2, 1, 2, 2, 3, 2, 1])
|
linewidths = cycler(linewidth=[1, 2, 1, 2, 2, 3, 2, 1])
|
||||||
|
|
||||||
linestyles = cycler(linestyle=['-', '-', '--', ':', '-', '--', ':', '-.', ])
|
linestyles = cycler(
|
||||||
|
linestyle=['-', '-', '--', ':', '-', '--', ':', '-.', ])
|
||||||
|
|
||||||
self._ax = []
|
self._ax = []
|
||||||
self._legend = {}
|
self._legend = {}
|
||||||
@ -75,8 +73,7 @@ class Figure:
|
|||||||
for ax in self._ax:
|
for ax in self._ax:
|
||||||
ax.grid(True, 'both')
|
ax.grid(True, 'both')
|
||||||
self._zorder -= 1
|
self._zorder -= 1
|
||||||
if not getReportQuality():
|
self.fig.show()
|
||||||
self._f.show()
|
|
||||||
|
|
||||||
def vline(self, x):
|
def vline(self, x):
|
||||||
self._ax[0].axvline(x)
|
self._ax[0].axvline(x)
|
||||||
@ -121,7 +118,7 @@ class Figure:
|
|||||||
self._cur_ax.legend(self._legend[self._cur_col][self._cur_col])
|
self._cur_ax.legend(self._legend[self._cur_col][self._cur_col])
|
||||||
|
|
||||||
def savefig(self, *args, **kwargs):
|
def savefig(self, *args, **kwargs):
|
||||||
self._f.savefig(*args, **kwargs)
|
self.fig.savefig(*args, **kwargs)
|
||||||
|
|
||||||
def xlim(self, *args, **kwargs):
|
def xlim(self, *args, **kwargs):
|
||||||
all_ax = kwargs.pop('all_ax', False)
|
all_ax = kwargs.pop('all_ax', False)
|
||||||
|
Loading…
Reference in New Issue
Block a user