Coverage for src/pyensae/graphhelper/matplotlib_helper.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-03 02:16 +0200

1# -*- coding: utf-8 -*- 

2""" 

3@file 

4@brief Various functions about :epkg:`matplotlib`. 

5""" 

6import sys 

7 

8 

9def mpl_switch_style(style="ggplot"): 

10 """ 

11 Changes the graph style. 

12 

13 :param style: see `Customizing plots with style sheets 

14 <http://matplotlib.org/users/style_sheets.html>`_ 

15 """ 

16 # This import was moved here because ths code is executed when 

17 # the module is imported and for some reasons, it overides some of the settings 

18 # sphinx is doing and graphs are not part of the documentation but show up 

19 # in a separate window. 

20 if "plt" not in sys.modules: 

21 import matplotlib.pyplot as plt # pylint: disable=C0415 

22 plt.style.use(style)