report_quality to init_backend.

This commit is contained in:
Anne de Jong 2018-10-04 15:41:15 +02:00 committed by J.A. de Jong - ASCEE
parent 38d1cfe435
commit 31243bcc6f
3 changed files with 36 additions and 40 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from .config import report_quality
from .report_tools import *
from .config import init_backend
from lasp.lasp_common import FreqWeighting, TimeWeighting
__all__ = ['report_quality', 'PSPlot', 'LevelBars', 'Levels', 'close',
__all__ = ['init_backend',
'FreqWeighting', 'TimeWeighting']

View File

@ -5,40 +5,40 @@ Author: J.A. de Jong - ASCEE
Description:
"""
__all__ = ['report_quality', 'getReportQuality']
__all__ = ['init_backend', 'getReportQuality']
_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():
global _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

View File

@ -15,9 +15,6 @@ from lasp.lasp_common import (PLOT_COLORS_LIST, PLOT_NOCOLORS_LIST,
DEFAULT_FIGSIZE_H, DEFAULT_FIGSIZE_W)
def close():
plt.close('all')
class Figure:
def __init__(self, **kwargs):
@ -43,7 +40,8 @@ class Figure:
linewidths = cycler(linewidth=[1, 2, 1, 2, 2, 3, 2, 1])
linestyles = cycler(linestyle=['-', '-', '--', ':', '-', '--', ':', '-.', ])
linestyles = cycler(
linestyle=['-', '-', '--', ':', '-', '--', ':', '-.', ])
self._ax = []
self._legend = {}
@ -75,8 +73,7 @@ class Figure:
for ax in self._ax:
ax.grid(True, 'both')
self._zorder -= 1
if not getReportQuality():
self._f.show()
self.fig.show()
def vline(self, x):
self._ax[0].axvline(x)
@ -121,7 +118,7 @@ class Figure:
self._cur_ax.legend(self._legend[self._cur_col][self._cur_col])
def savefig(self, *args, **kwargs):
self._f.savefig(*args, **kwargs)
self.fig.savefig(*args, **kwargs)
def xlim(self, *args, **kwargs):
all_ax = kwargs.pop('all_ax', False)