scattertext/__init__.py
def produce_four_square_axes_explorer(four_square_axes,
                                      x_label=None,
                                      y_label=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
    ----------
    four_square : FourSquareAxes
        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.
    not_b_category_name: str or None
        Name of neutral set of data.  Defaults to "Extra".
    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 x_label is None:
        x_label = four_square_axes.left_category_name_ + '-' + four_square_axes.right_category_name_
    if y_label is None:
        y_label = four_square_axes.top_category_name_ + '-' + four_square_axes.bottom_category_name_

    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)})'
    axes = four_square_axes.get_axes()

    if 'scores' not in kwargs:
        kwargs['scores'] = -axes['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
    '''
    return produce_scattertext_explorer(
        four_square_axes.term_doc_matrix_,
        category=four_square_axes.left_categories_[0],
        category_name=four_square_axes.left_category_name_,
        not_categories=four_square_axes.right_categories_,
        not_category_name=four_square_axes.right_category_name_,
        neutral_categories=four_square_axes.top_categories_,
        neutral_category_name=four_square_axes.top_category_name_,
        extra_categories=four_square_axes.bottom_categories_,
        extra_category_name=four_square_axes.bottom_category_name_,
        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=four_square_axes,
        show_neutral=True,
        show_extra=True,
        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
    ----------
    four_square : FourSquareAxes
        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.
    not_b_category_name: str or None
        Name of neutral set of data.  Defaults to "Extra".
    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

four_square : FourSquareAxes
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 four_square : FourSquareAxes The basis of the visualization x_label : str The x - axis label in the scatter plot . Returns str html of visualization
def produce_four_square_axes_explorer(four_square_axes,
                                      x_label=None,
                                      y_label=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 x_label is None:
        x_label = four_square_axes.left_category_name_ + '-' + four_square_axes.right_category_name_
    if y_label is None:
        y_label = four_square_axes.top_category_name_ + '-' + four_square_axes.bottom_category_name_
    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 = four_square_axes.get_axes()
    if 'scores' not in kwargs:
        kwargs['scores'] = -axes['x']
    return produce_scattertext_explorer(
        four_square_axes.term_doc_matrix_,
        category=four_square_axes.left_categories_[0],
        category_name=four_square_axes.left_category_name_,
        not_categories=four_square_axes.right_categories_,
        not_category_name=four_square_axes.right_category_name_,
        neutral_categories=four_square_axes.top_categories_,
        neutral_category_name=four_square_axes.top_category_name_,
        extra_categories=four_square_axes.bottom_categories_,
        extra_category_name=four_square_axes.bottom_category_name_,
        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=four_square_axes,
        show_neutral=True,
        show_extra=True,
        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_four_square_axes_explorer ( four_square_axes , x_label = None , y_label = 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 x_label is None : x_label = four_square_axes . left_category_name_ + '-' + four_square_axes . right_category_name_ if y_label is None : y_label = four_square_axes . top_category_name_ + '-' + four_square_axes . bottom_category_name_ 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 = four_square_axes . get_axes ( ) if 'scores' not in kwargs : kwargs [ 'scores' ] = - axes [ '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
    ''' return produce_scattertext_explorer ( four_square_axes . term_doc_matrix_ , category = four_square_axes . left_categories_ [ 0 ] , category_name = four_square_axes . left_category_name_ , not_categories = four_square_axes . right_categories_ , not_category_name = four_square_axes . right_category_name_ , neutral_categories = four_square_axes . top_categories_ , neutral_category_name = four_square_axes . top_category_name_ , extra_categories = four_square_axes . bottom_categories_ , extra_category_name = four_square_axes . bottom_category_name_ , 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 = four_square_axes , show_neutral = True , show_extra = True , 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
    ----------
    four_square : FourSquareAxes
        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.
    not_b_category_name: str or None
        Name of neutral set of data.  Defaults to "Extra".
    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
    '''
four_square_axes
x_label
y_label
num_terms_semiotic_square
get_tooltip_content
x_axis_values
y_axis_values
color_func
axis_scaler