figures_tests.py 1.41 KB
Newer Older
Yori Fournier's avatar
Yori Fournier committed
1
# IMPORT ---------------------------------------------------------------
2
3
from myplotlib import MplFig
from axes_tests import AxTest
Yori Fournier's avatar
Yori Fournier committed
4

5
class FigTest(MplFig):                                                  
Yori Fournier's avatar
Yori Fournier committed
6
7
8
9
10
11
12
13
  
    FIGSIZE = (8., 6.)
    
    def addAxes(self):
        
        ratio = 6. / 8.  # height/width of the axes (in inch)
        frame1 = [0.1, 0.1, 0.8, 0.8]  # part of the fig that is available
        
14
        self.add_axes(AxTest(self), "p1")
15

16
class FigTest2(MplFig):                                                  # Fig with two Axes
17
18
19
20
21
22
23
24
25
26
27
  
    # Set the size of the Figure in inch
    # (private variable can not be updated)
    FIGSIZE = (8., 6.)
    
    def addAxes(self):
        
        ratio = 6. / 8.  # height/width of the axes (in inch)
        frame1 = [0.1, 0.1, 0.4, 0.8]  # part of the fig that is available
        frame2 = [0.6, 0.1, 0.4, 0.8]  # part of the fig that is available
        
28
29
        self.add_axes(AxTest(self),"p1")
        self.add_axes(AxTest(self),"p2")
30
        
31
    def declare_aliases(self):
32
33
34
        
        # it is important to not hold additional references to an axes in the figure to avoid memory leaks. use the this function
        # get the plot added above
35
36
        p1 = self.get_axes_by_name("p1")
        p2 = self.get_axes_by_name("p2")
37
        
38
39
        self.aliases = {'x_range_p1': (p1, "x_range"),
                        'x_range_p2': (p2, "x_range")}
40
41
        
        return(True)