Commit b684b47e authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

merging tools, feature-design, and feature-aspect-ratio into dev

the test 200 does not work anymore due to feature-aspect-ratio
FigTest2 has been modified to take these modif into account

Need to test the new keywords forceRatioOn...

need to test design
parents a3cc654e c69a44cf
......@@ -92,8 +92,8 @@ rc('lines', markersize=6)
rc('axes', linewidth=1.5)
rc('xtick.major', width=1.5, pad=10., size=10.)
rc('ytick.major', width=1.5, pad=8., size=10.)
rc('xtick.minor', width=1.5, size=5.)
rc('ytick.minor', width=1.5, size=5.)
rc('xtick.minor', width=1.5, size=5., visible=False)
rc('ytick.minor', width=1.5, size=5., visible=False)
rc('figure', dpi = 75.0)
# FUNCTIONS ------------------------------------------------------------
......@@ -134,7 +134,7 @@ from .test import test600
# the tests to run
testList = [test100,
test200, test201, test202,
test201, test202,
test300, test301, test302, test303, test304, test305,
test306, test307, test308, test309, test310,
test400, test401, test402,
......
......@@ -52,47 +52,36 @@ class MyAxes(Axes):
# CONSTRUCTOR --------------------------------------------------------
def __init__(self, fig, ratio, frameRect, *args, **kwargs):
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
# get the size of the figure
figWidth = fig.get_figwidth()
figHeight = fig.get_figheight()
figDpi = fig.get_dpi()
# get the font size in inches
fontsize = rcParams['font.size'] / figDpi
self.fig = fig
# the largest width and height allowed in inches
maxWidth = figWidth * frameWidth - 8. * (figDpi / 75.) * fontsize
maxHeight = figHeight * frameHeight - 4. * (figDpi / 75.) * fontsize
rect = self.computeRect(ratio, frameRect, *args, **kwargs)
kwargs.pop('forceRatioOnWidth', None)
kwargs.pop('forceRatioOnHeight', None)
# the hypothetical width and height in inches
# for a given aspect ratio
hypoWidth = maxHeight / ratio
hypoHeight = maxWidth * ratio
# parent constructor
Axes.__init__(self, fig, rect, **kwargs)
# COMPUTE RECT -------------------------------------------------------
def computeRect(self, ratio, frameRect, *args, **kwargs):
# if the hypothetical width is larger that the
# maximum allowed width (in inches) then chose
# the hypothetical Height
if (hypoWidth > maxWidth):
height = hypoHeight / figHeight # height in percent
width = maxWidth / figWidth # width in percent
posX = framePosX + 4. * (figDpi / 75.) * fontsize / figWidth # posX
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight # posY
else:
height = maxHeight / figHeight
width = hypoWidth / figWidth
posX = framePosX + (frameWidth - width) / 2.
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight
# Get the optional keyword
forceRatioOnWidth = kwargs.pop('forceRatioOnWidth', None)
forceRatioOnHeight = kwargs.pop('forceRatioOnHeight', None)
rect = [posX, posY, width, height]
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
# parent constructor
Axes.__init__(self, fig, rect, **kwargs)
if(forceRatioOnWidth):
rect = [framePosX, framePosY, frameHeight/ratio, frameHeight]
elif(forceRatioOnHeight):
rect = [framePosX, framePosY, frameWidth, frameWidth*ratio]
else:
rect = [framePosX, framePosY, frameWidth, frameHeight]
return(rect)
self.fig = fig
# PLOTTING -----------------------------------------------------------
# the plotting function (need to be overwrite from child
def plotting(self):
......
......@@ -92,6 +92,6 @@ class FigTest2(MyFig):
def addAxes(self):
ratio = 6. / 8. # height/width of the axes (in inch)
frame = [0.0, 0.0, 1.0, 1.0] # part of the fig that is available
frame = [0.1, 0.1, 0.8, 0.8] # part of the fig that is available
self.add_axes(AxTest1(self, ratio, frame))
......@@ -66,7 +66,7 @@ def test100(debug):
return(status)
# TEST 2.00: test MyAxes Constructor
# TEST 2.00: test MyAxes Constructor --------------------- NOT UP-TO-DATE
#
# REMARK: Require to test MyFig First
#
......
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