scattertext/__init__.py
def produce_semiotic_square_explorer(semiotic_square,
                                     x_label,
                                     y_label,
                                     category_name=None,
                                     not_category_name=None,
                                     neutral_category_name=None,
                                     num_terms_semiotic_square=None,
                                     get_tooltip_content=None,
                                     x_axis_values=None,
                                     y_axis_values=None,
                                     color_func=None,
                                     axis_scaler=scale_neg_1_to_1_with_zero_mean,
                                     **kwargs):
    '''
    Produces a semiotic square visualization.

    Parameters
    ----------
    semiotic_square : SemioticSquare
        The basis of the visualization
    x_label : str
        The x-axis label in the scatter plot.  Relationship between `category_a` and `category_b`.
    y_label
        The y-axis label in the scatter plot.  Relationship neutral term and complex term.
    category_name : str or None
        Name of category to use.  Defaults to category_a.
    not_category_name : str or None
        Name of everything that isn't in category.  Defaults to category_b.
    neutral_category_name : str or None
        Name of neutral set of data.  Defaults to "Neutral".
    num_terms_semiotic_square : int or None
        10 by default. Number of terms to show in semiotic square.
    get_tooltip_content : str or None
        Defaults to tooltip showing z-scores on both axes.
    x_axis_values : list, default None
        Value-labels to show on x-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    y_axis_values : list, default None
        Value-labels to show on y-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    color_func : str, default None
        Javascript function to control color of a point.  Function takes a parameter
        which is a dictionary entry produced by `ScatterChartExplorer.to_dict` and
        returns a string. Defaults to RdYlBl on x-axis, and varying saturation on y-axis.
    axis_scaler : lambda, default scale_neg_1_to_1_with_zero_mean_abs_max
        Scale values to fit axis
    Remaining arguments are from `produce_scattertext_explorer`.

    Returns
    -------
        str, html of visualization
    '''
    if category_name is None:
        category_name = semiotic_square.category_a_
    if not_category_name is None:
        not_category_name = semiotic_square.category_b_

    if get_tooltip_content is None:
        get_tooltip_content = '''(function(d) {return d.term + "<br/>%s: " + Math.round(d.ox*1000)/1000+"<br/>%s: " + Math.round(d.oy*1000)/1000})''' \
                              % (x_label, y_label)
    if color_func is None:
        # this desaturates
        # color_func = '(function(d) {var c = d3.hsl(d3.interpolateRdYlBu(d.x)); c.s *= d.y; return c;})'
        color_func = '(function(d) {return d3.interpolateRdYlBu(d.x)})'
    '''
    my_scaler = scale_neg_1_to_1_with_zero_mean_abs_max
    if foveate:
        my_scaler = scale_neg_1_to_1_with_zero_mean_rank_abs_max
    '''
    axes = semiotic_square.get_axes()
    return produce_scattertext_explorer(semiotic_square.term_doc_matrix_,
                                        category=semiotic_square.category_a_,
                                        category_name=category_name,
                                        not_category_name=not_category_name,
                                        not_categories=[semiotic_square.category_b_],
                                        scores=-axes['x'],
                                        sort_by_dist=False,
                                        x_coords=axis_scaler(-axes['x']),
                                        y_coords=axis_scaler(axes['y']),
                                        original_x=-axes['x'],
                                        original_y=axes['y'],
                                        show_characteristic=False,
                                        show_top_terms=False,
                                        x_label=x_label,
                                        y_label=y_label,
                                        semiotic_square=semiotic_square,
                                        neutral_categories=semiotic_square.neutral_categories_,
                                        show_neutral=True,
                                        neutral_category_name=neutral_category_name,
                                        num_terms_semiotic_square=num_terms_semiotic_square,
                                        get_tooltip_content=get_tooltip_content,
                                        x_axis_values=x_axis_values,
                                        y_axis_values=y_axis_values,
                                        color_func=color_func,
                                        show_axes=False,
                                        **kwargs)

    Produces a semiotic square visualization.

    Parameters
    ----------
    semiotic_square : SemioticSquare
        The basis of the visualization
    x_label : str
        The x-axis label in the scatter plot.  Relationship between `category_a` and `category_b`.
    y_label
        The y-axis label in the scatter plot.  Relationship neutral term and complex term.
    category_name : str or None
        Name of category to use.  Defaults to category_a.
    not_category_name : str or None
        Name of everything that isn't in category.  Defaults to category_b.
    neutral_category_name : str or None
        Name of neutral set of data.  Defaults to "Neutral".
    num_terms_semiotic_square : int or None
        10 by default. Number of terms to show in semiotic square.
    get_tooltip_content : str or None
        Defaults to tooltip showing z-scores on both axes.
    x_axis_values : list, default None
        Value-labels to show on x-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    y_axis_values : list, default None
        Value-labels to show on y-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    color_func : str, default None
        Javascript function to control color of a point.  Function takes a parameter
        which is a dictionary entry produced by `ScatterChartExplorer.to_dict` and
        returns a string. Defaults to RdYlBl on x-axis, and varying saturation on y-axis.
    axis_scaler : lambda, default scale_neg_1_to_1_with_zero_mean_abs_max
        Scale values to fit axis
    Remaining arguments are from `produce_scattertext_explorer`.

    Returns
    -------
        str, html of visualization
    
Produces a semiotic square visualization.
Parameters

semiotic_square : SemioticSquare
The basis of the visualization
x_label : str
The x-axis label in the scatter plot.

Returns

str, html of visualization
Produces a semiotic square visualization . Parameters semiotic_square : SemioticSquare The basis of the visualization x_label : str The x - axis label in the scatter plot . Returns str html of visualization
def produce_semiotic_square_explorer(semiotic_square,
                                     x_label,
                                     y_label,
                                     category_name=None,
                                     not_category_name=None,
                                     neutral_category_name=None,
                                     num_terms_semiotic_square=None,
                                     get_tooltip_content=None,
                                     x_axis_values=None,
                                     y_axis_values=None,
                                     color_func=None,
                                     axis_scaler=scale_neg_1_to_1_with_zero_mean,
                                     **kwargs):
    if category_name is None:
        category_name = semiotic_square.category_a_
    if not_category_name is None:
        not_category_name = semiotic_square.category_b_
    if get_tooltip_content is None:
        get_tooltip_content = '''(function(d) {return d.term + "<br/>%s: " + Math.round(d.ox*1000)/1000+"<br/>%s: " + Math.round(d.oy*1000)/1000})''' \
                              % (x_label, y_label)
    if color_func is None:
        color_func = '(function(d) {return d3.interpolateRdYlBu(d.x)})'
    axes = semiotic_square.get_axes()
    return produce_scattertext_explorer(semiotic_square.term_doc_matrix_,
                                        category=semiotic_square.category_a_,
                                        category_name=category_name,
                                        not_category_name=not_category_name,
                                        not_categories=[semiotic_square.category_b_],
                                        scores=-axes['x'],
                                        sort_by_dist=False,
                                        x_coords=axis_scaler(-axes['x']),
                                        y_coords=axis_scaler(axes['y']),
                                        original_x=-axes['x'],
                                        original_y=axes['y'],
                                        show_characteristic=False,
                                        show_top_terms=False,
                                        x_label=x_label,
                                        y_label=y_label,
                                        semiotic_square=semiotic_square,
                                        neutral_categories=semiotic_square.neutral_categories_,
                                        show_neutral=True,
                                        neutral_category_name=neutral_category_name,
                                        num_terms_semiotic_square=num_terms_semiotic_square,
                                        get_tooltip_content=get_tooltip_content,
                                        x_axis_values=x_axis_values,
                                        y_axis_values=y_axis_values,
                                        color_func=color_func,
                                        show_axes=False,
                                        **kwargs)
def produce_semiotic_square_explorer ( semiotic_square , x_label , y_label , category_name = None , not_category_name = None , neutral_category_name = None , num_terms_semiotic_square = None , get_tooltip_content = None , x_axis_values = None , y_axis_values = None , color_func = None , axis_scaler = scale_neg_1_to_1_with_zero_mean , ** kwargs ) : if category_name is None : category_name = semiotic_square . category_a_ if not_category_name is None : not_category_name = semiotic_square . category_b_ if get_tooltip_content is None : get_tooltip_content = '''(function(d) {return d.term + "<br/>%s: " + Math.round(d.ox*1000)/1000+"<br/>%s: " + Math.round(d.oy*1000)/1000})''' % ( x_label , y_label ) if color_func is None : color_func = '(function(d) {return d3.interpolateRdYlBu(d.x)})' '''
    my_scaler = scale_neg_1_to_1_with_zero_mean_abs_max
    if foveate:
        my_scaler = scale_neg_1_to_1_with_zero_mean_rank_abs_max
    ''' axes = semiotic_square . get_axes ( ) return produce_scattertext_explorer ( semiotic_square . term_doc_matrix_ , category = semiotic_square . category_a_ , category_name = category_name , not_category_name = not_category_name , not_categories = [ semiotic_square . category_b_ ] , scores = - axes [ 'x' ] , sort_by_dist = False , x_coords = axis_scaler ( - axes [ 'x' ] ) , y_coords = axis_scaler ( axes [ 'y' ] ) , original_x = - axes [ 'x' ] , original_y = axes [ 'y' ] , show_characteristic = False , show_top_terms = False , x_label = x_label , y_label = y_label , semiotic_square = semiotic_square , neutral_categories = semiotic_square . neutral_categories_ , show_neutral = True , neutral_category_name = neutral_category_name , num_terms_semiotic_square = num_terms_semiotic_square , get_tooltip_content = get_tooltip_content , x_axis_values = x_axis_values , y_axis_values = y_axis_values , color_func = color_func , show_axes = False , ** kwargs )
Produces a semiotic square visualization.
Produces a semiotic square visualization .
'''
    Produces a semiotic square visualization.

    Parameters
    ----------
    semiotic_square : SemioticSquare
        The basis of the visualization
    x_label : str
        The x-axis label in the scatter plot.  Relationship between `category_a` and `category_b`.
    y_label
        The y-axis label in the scatter plot.  Relationship neutral term and complex term.
    category_name : str or None
        Name of category to use.  Defaults to category_a.
    not_category_name : str or None
        Name of everything that isn't in category.  Defaults to category_b.
    neutral_category_name : str or None
        Name of neutral set of data.  Defaults to "Neutral".
    num_terms_semiotic_square : int or None
        10 by default. Number of terms to show in semiotic square.
    get_tooltip_content : str or None
        Defaults to tooltip showing z-scores on both axes.
    x_axis_values : list, default None
        Value-labels to show on x-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    y_axis_values : list, default None
        Value-labels to show on y-axis. [-2.58, -1.96, 0, 1.96, 2.58] is the default
    color_func : str, default None
        Javascript function to control color of a point.  Function takes a parameter
        which is a dictionary entry produced by `ScatterChartExplorer.to_dict` and
        returns a string. Defaults to RdYlBl on x-axis, and varying saturation on y-axis.
    axis_scaler : lambda, default scale_neg_1_to_1_with_zero_mean_abs_max
        Scale values to fit axis
    Remaining arguments are from `produce_scattertext_explorer`.

    Returns
    -------
        str, html of visualization
    ''' # this desaturates # color_func = '(function(d) {var c = d3.hsl(d3.interpolateRdYlBu(d.x)); c.s *= d.y; return c;})' '''
    my_scaler = scale_neg_1_to_1_with_zero_mean_abs_max
    if foveate:
        my_scaler = scale_neg_1_to_1_with_zero_mean_rank_abs_max
    '''
semiotic_square
x_label
y_label
category_name
not_category_name
neutral_category_name
num_terms_semiotic_square
get_tooltip_content
x_axis_values
y_axis_values
color_func
axis_scaler