Commit 52483d05 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update controller graph and graph_tools to define plot style (matplotlib 2.2.3)

parent ad8fd5d9
...@@ -12,11 +12,15 @@ from gluon.storage import Storage ...@@ -12,11 +12,15 @@ from gluon.storage import Storage
from graph_tools import (FROM_TO, from graph_tools import (FROM_TO,
LABELY_YEAR, LABELY_YEAR,
linechart, linechart,
mplstyle,
savefig, savefig,
stackchart) stackchart)
from model_selector import YEAR_SUBMIT from model_selector import YEAR_SUBMIT
mplstyle()
def dashboard(): def dashboard():
"""Return a pre-configure linechart for public used. """Return a pre-configure linechart for public used.
Cumulative distribution for the publications are shown for Cumulative distribution for the publications are shown for
......
...@@ -145,6 +145,30 @@ def emptychart(db, selector, target=None): ...@@ -145,6 +145,30 @@ def emptychart(db, selector, target=None):
return ax return ax
def mplstyle():
"""Helper function to define matplotlib style for plots.
"""
mpl.rcParams["font.size"] = 8
mpl.rcParams["grid.alpha"] = 0.5
mpl.rcParams["grid.linestyle"] = "dotted"
mpl.rcParams["xtick.direction"] = "in"
mpl.rcParams["xtick.top"] = True
mpl.rcParams["xtick.bottom"] = True
mpl.rcParams["xtick.major.size"] = 8
mpl.rcParams["xtick.minor.size"] = 4
mpl.rcParams["xtick.labelsize"] = 8
mpl.rcParams["ytick.direction"] = "in"
mpl.rcParams["ytick.left"] = True
mpl.rcParams["ytick.right"] = True
mpl.rcParams["ytick.major.size"] = 8
mpl.rcParams["ytick.minor.size"] = 4
mpl.rcParams["ytick.labelsize"] = 8
def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None): def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None):
"""Build a line chart showing the number of publications as a function """Build a line chart showing the number of publications as a function
of the time. of the time.
...@@ -211,8 +235,6 @@ def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None): ...@@ -211,8 +235,6 @@ def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None):
# #
# instantiate the graph # instantiate the graph
# #
mpl.rcParams['legend.fontsize'] = 10
if is_submit_month: if is_submit_month:
df.index = DatetimeIndex(df.index) df.index = DatetimeIndex(df.index)
...@@ -495,8 +517,6 @@ def stackchart(db, selector, target=None): ...@@ -495,8 +517,6 @@ def stackchart(db, selector, target=None):
# #
# instantiate the graph # instantiate the graph
# #
mpl.rcParams['legend.fontsize'] = 10
kwargs = {} kwargs = {}
if is_submit_month: if is_submit_month:
df.index = DatetimeIndex(df.index) df.index = DatetimeIndex(df.index)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment