1
+ import matplotlib as mpl
2
+ import matplotlib .pyplot as plt
3
+ from kivy .metrics import dp
4
+
5
+ #optimized draw on Agg backend
6
+ mpl .rcParams ['path.simplify' ] = True
7
+ mpl .rcParams ['path.simplify_threshold' ] = 1.0
8
+ mpl .rcParams ['agg.path.chunksize' ] = 1000
9
+
10
+ #define some matplotlib figure parameters
11
+ mpl .rcParams ['font.family' ] = 'Verdana'
12
+ mpl .rcParams ['axes.spines.top' ] = False
13
+ mpl .rcParams ['axes.spines.right' ] = False
14
+ mpl .rcParams ['axes.linewidth' ] = 1.0
15
+
16
+ font_size_axis_title = dp (13 )
17
+ font_size_axis_tick = dp (12 )
18
+
19
+ class GraphGenerator (object ):
20
+ """class that generate Matplotlib graph."""
21
+
22
+ def __init__ (self ):
23
+ """Create empty structure plot.
24
+
25
+ """
26
+ super ().__init__ ()
27
+
28
+ self .fig , self .ax1 = plt .subplots (1 , 1 )
29
+
30
+ self .line1 , = self .ax1 .plot ([0 ,1 ,2 ,3 ,4 ], [1 ,2 ,8 ,9 ,4 ],label = 'line1' )
31
+ self .line2 , = self .ax1 .plot ([2 ,8 ,10 ,15 ], [15 ,0 ,2 ,4 ],label = 'line2' )
32
+
33
+ self .xmin ,self .xmax = self .ax1 .get_xlim ()
34
+ self .ymin ,self .ymax = self .ax1 .get_ylim ()
35
+
36
+ self .fig .subplots_adjust (left = 0.13 ,top = 0.96 ,right = 0.93 ,bottom = 0.2 )
37
+
38
+ self .ax1 .set_xlim (self .xmin , self .xmax )
39
+ self .ax1 .set_ylim (self .ymin , self .ymax )
40
+ self .ax1 .set_xlabel ("axis_x" ,fontsize = font_size_axis_title )
41
+ self .ax1 .set_ylabel ("axis_y" ,fontsize = font_size_axis_title )#
42
+
0 commit comments