def colorCrosstabResiduals(obj, i, j, numrows, numcols, section, more, custom):
    if section == "datacells":
        try:
            if abs(floatex(obj.GetValueAt(i, j))) >= custom.get("thresh", 2.0):
                for k in range(custom.get("number", 1) + 1):
                    obj.SetBackgroundColorAt(i - k, j, RGB((255, 0, 0)))
                obj.SetBackgroundColorAt(i - 1, j, RGB((255, 0, 0)))
        except:
            pass
def washColumnsBlue(obj, i, j, numrows, numcols, section, more):
    """color cells backgrounds from dark  to light"""

    mincolor = 150.
    maxcolor = 255.
    increment = (maxcolor - mincolor) / (numcols - 1)
    colorvalue = round(mincolor + increment * j)
    obj.SetBackgroundColorAt(i, j, RGB((mincolor, mincolor, colorvalue)))
def stripeOddRows2(obj, i, j, numrows, numcols, section, more, custom):
    """stripe odd rows with color parameters
    
    extra parameters are r, g, b"""

    if i % 2 == 1:
        # retrieve three parameters with defaults and calculate color value first time then add to dictionary
        if custom["_first"]:
            custom["_color"] = RGB(
                (custom.get('r', 0), custom.get('g', 0), custom.get('b', 200)))
            custom["_first"] = False
        obj.SetBackgroundColorAt(i, j, custom["_color"])
def colorIfEndsWithAtoZLetter(obj, i, j, numrows, numcols, section, more,
                              custom):
    """set the background color of any cell that ends with a letter code
    
    custom parameters are the red, green, and blue codes as r, g, b
    Default color is yellow (255,255,0)"""

    if custom["_first"]:
        custom["_color"] = RGB(
            (custom.get('r', 255), custom.get('g', 255), custom.get('b', 0)))
        custom["_first"] = False

    if section == 'datacells':
        v = obj.GetValueAt(i, j)
        if v[-1] in AtoZ:
            obj.SetBackgroundColorAt(i, j, custom["_color"])
def washColumns(obj, i, j, numrows, numcols, section, more, custom):
    """color cells backgrounds from dark  to light
    
    parameter color = "red", "green", or "blue" determines the background color"""

    validcolors = ["red", "green", "blue"]
    dim = custom.get("color", "blue").lower()  # get user-specified color
    try:
        index = validcolors.index(dim)
    except:
        raise ValueError(
            "Invalid color parameter for function washColumns: %s" % dim)

    mincolor = 150.
    maxcolor = 255.
    increment = (maxcolor - mincolor) / (numcols - 1)
    colorvalue = round(mincolor + increment * j)
    color = [mincolor, mincolor, mincolor]
    color[index] = colorvalue
    obj.SetBackgroundColorAt(i, j, RGB(color))
def stripeOddRows(obj, i, j, numrows, numcols, section, more):
    """Color background of odd number rows for data and labels"""

    if i % 2 == 1:
        obj.SetBackgroundColorAt(i, j, RGB((0, 0, 200)))
def stripeOddDataRows(obj, i, j, numrows, numcols, section, more):
    """Color background of odd number rows for data portion"""

    if section == "datacells" and i % 2 == 1:
        obj.SetBackgroundColorAt(i, j, RGB((0, 0, 200)))
def stripeOddDataRowsAndAlign(obj, i, j, numrows, numcols, section, more):
    """Color background of odd number rows for data portion"""

    if section == "datacells" and i % 2 == 1:
        obj.SetBackgroundColorAt(i, j, RGB((0, 0, 200)))
        obj.SetHAlignAt(i, j, SpssClient.SpssHAlignTypes.SpssHAlLeft)
def pastelqualitative(obj, i, j, numrows, numcols, section, more):
    """color cells backgrounds using Pastel Qualitative scheme
    good for up to 9 columns."""

    obj.SetBackgroundColorAt(i, j, RGB(PastelQualitative[min(j, 8)]))
def qualitative(obj, i, j, numrows, numcols, section, more):
    """color cells backgrounds using qualitative scheme
    good for up to 12 columns."""

    obj.SetBackgroundColorAt(i, j, RGB(Set3Qualitative[min(j, 11)]))
示例#11
0
# 08-feb-2015 add option to bold significant correlations

# function RGB takes a list of three values and returns the RGB value
# function floatex decodes a numeric string value to its float value taking the cell format into account


import SpssClient   # for text constants
from modifytables import RGB
from extension import floatex  # strings to floats
from spssaux import getSpssVersion

ver=[int(v) for v in getSpssVersion().split(".")]
hidelok = ver[0] >= 19 or (ver[0] == 18 and ver[1] > 0 or (ver[1] == 0 and ver[2] >= 3))

# behavior settings
color = RGB((251, 248, 115))      # yellow
BSIZE=3   # number of statistics rows in table
style = SpssClient.SpssTextStyleTypes.SpssTSBold

def cleancorr(obj, i, j, numrows, numcols, section, more, custom):
    """Clean correlation matrix
    
    parameters:
    hideN   - hide count rows
    hideL   - hide statistics label
    lowertri - show only lower triangle
    hideinsig - threshold for hiding insignificant coefs - default .05
    emphlarge - threshold for emphasizing large correlations - default .5
    emphasis - synonym for emphlarge
    decimals - number of decimal places
    boldsig - bold significant correlations