Coverage for src/driada/utils/plot.py: 76.92%

26 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-25 15:40 +0300

1import matplotlib.pyplot as plt 

2import matplotlib.pylab as pylab 

3 

4 

5def make_beautiful(ax): 

6 for axis in ['bottom', 'left']: 

7 ax.spines[axis].set_linewidth(4) 

8 ax.tick_params(width=4, direction='in', length=8, pad=15) 

9 

10 for axis in ['top', 'right']: 

11 ax.spines[axis].set_linewidth(0.0) 

12 

13 # ax.locator_params(axis='x', nbins=8) 

14 # ax.locator_params(axis='y', nbins=8) 

15 ax.tick_params(axis='x', which='major', labelsize=26) 

16 ax.tick_params(axis='y', which='major', labelsize=26) 

17 

18 ax.xaxis.label.set_size(30) 

19 ax.yaxis.label.set_size(30) 

20 

21 params = {'legend.fontsize': 18, 

22 'axes.titlesize': 30, 

23 } 

24 

25 pylab.rcParams.update(params) 

26 

27 return ax 

28 

29 

30def create_default_figure(a=16, b=12): 

31 fig, ax = plt.subplots(figsize=(a, b)) 

32 ax = make_beautiful(ax) 

33 

34 return fig, ax 

35 

36 

37def plot_mat(mat, a=12, b=12, ax=None, with_cbar=True): 

38 if ax is None: 

39 fig, ax = plt.subplots(figsize=(a, b)) 

40 

41 im = ax.imshow(mat) 

42 if with_cbar: 

43 cbar = ax.figure.colorbar(im, ax=ax) 

44 

45 return ax