<commit_before>function y_rug(args) {
    var svg = d3.select(args.target + ' svg');
    var buffer_size = args.chart_type == 'point' 
        ? args.buffer / 2 
        : args.buffer * 2 / 3;

    var all_data = [];
    for (var i=0; i<args.data.length; i++) {
        for (var j=0; j<args.data[i].length; j++) {
            all_data.push(args.data[i][j]);
        }
    }
    var rug = svg.selectAll('line.y_rug').data(all_data)
        .enter().append('svg:line')
            .attr('x1', args.left + 1)
            .attr('x2', args.left+buffer_size)
            .attr('y1', args.scalefns.yf)
            .attr('y2', args.scalefns.yf)
            .attr('class', 'y-rug')
            .attr('opacity', 0.3);

    if (args.color_accessor) {
        rug.attr('stroke', args.scalefns.color);
    }
    else {
        rug.classed('y-rug-mono', true);
    }
}

function y_axis(args) {
    var svg = d3.select(args.target + ' svg');
    var g;

    var min_y, max_y;

    args.scalefns.yf = function(di) {
        return args.scales.Y(di[args.y_accessor]);
    }

    var min_y, max_y;

    var _set = false;
    for (var i=0; i<args.data.length; i++) {
        var a = args.data[i];

        if (args.y_scale_type == 'log') {
            // filter positive values
            a = a.filter(function(d) { return d[args.y_accessor] > 0; });
        }

        if (a.length > 0) {
            // get min/max in one pass
            var extent = d3.extent(a,function(d) {
                return d[args.y_accessor];
            });

            if (!_set) {
                // min_y and max_y haven't been set
                min_y = extent[0];
                max_y = extent[1];
                _set = true;
            } else {
                min_y = Math.min(extent[0], min_y);
                max_y = Math.max(extent[1], max_y);
            }
        }
    }

    if (min_y >=0 && !args.min_y && !args.use_data_y_min){
        min_y=0;
    }

    min_y = args.min_y ? args.min_y : min_y;
    max_y = args.max_y ? args.max_y : max_y;

    if (args.y_scale_type != 'log') {
        // we are currently saying that if the min val > 0, set 0 as min y.
        if (min_y >= 0){
            //min_y = 0;
            args.y_axis_negative = false;
        } else {
            min_y = min_y  - (max_y * (args.inflator-1));
            args.y_axis_negative = true;
        }
    }

    max_y = max_y * args.inflator;
    if (!args.min_y && args.use_data_y_min){
        min_y = min_y / args.inflator;    
    }
    

    if (args.y_scale_type == 'log'){
        if (args.chart_type == 'histogram') {
            // log histogram plots should start just below 1
            // so that bins with single counts are visible
            min_y = 0.2;
        } else {
            if (min_y <= 0) {
                min_y = 1;
            }
        }
        args.scales.Y = d3.scale.log()
            .domain([min_y, max_y])
            .range([args.height - args.bottom - args.buffer, args.top])
            .clamp(true);
    } else {
        args.scales.Y = d3.scale.linear()
            .domain([min_y, max_y])
            .range([args.height - args.bottom - args.buffer, args.top]);
    }

    // used for ticks and such, and designed to be paired with log or linear.
    args.scales.Y_axis = d3.scale.linear()
        .domain([min_y, max_y])
        .range([args.height - args.bottom - args.buffer, args.top]);

    var yax_format;
    if (args.format == 'count') {
        yax_format = function(f) {
            if (f < 1.0) {
                // Don't scale tiny values.
                return args.yax_units + d3.round(f, args.decimals);
            } else {
                var pf = d3.formatPrefix(f);<commit_msg>Added comments (issue #196)<commit_after>function y_rug(args) {
    var svg = d3.select(args.target + ' svg');
    var buffer_size = args.chart_type == 'point' 
        ? args.buffer / 2 
        : args.buffer * 2 / 3;

    var all_data = [];
    for (var i=0; i<args.data.length; i++) {
        for (var j=0; j<args.data[i].length; j++) {
            all_data.push(args.data[i][j]);
        }
    }
    var rug = svg.selectAll('line.y_rug').data(all_data)
        .enter().append('svg:line')
            .attr('x1', args.left + 1)
            .attr('x2', args.left+buffer_size)
            .attr('y1', args.scalefns.yf)
            .attr('y2', args.scalefns.yf)
            .attr('class', 'y-rug')
            .attr('opacity', 0.3);

    if (args.color_accessor) {
        rug.attr('stroke', args.scalefns.color);
    }
    else {
        rug.classed('y-rug-mono', true);
    }
}

function y_axis(args) {
    var svg = d3.select(args.target + ' svg');
    var g;

    var min_y, max_y;

    args.scalefns.yf = function(di) {
        return args.scales.Y(di[args.y_accessor]);
    }

    var min_y, max_y;

    var _set = false;
    for (var i=0; i<args.data.length; i++) {
        var a = args.data[i];

        if (args.y_scale_type == 'log') {
            // filter positive values
            a = a.filter(function(d) { return d[args.y_accessor] > 0; });
        }

        if (a.length > 0) {
            // get min/max in one pass
            var extent = d3.extent(a,function(d) {
                return d[args.y_accessor];
            });

            if (!_set) {
                // min_y and max_y haven't been set
                min_y = extent[0];
                max_y = extent[1];
                _set = true;
            } else {
                min_y = Math.min(extent[0], min_y);
                max_y = Math.max(extent[1], max_y);
            }
        }
    }

    // the default cause is for the y-axis to start at 0, unless we explicitly want it
    // to start at ab arbitrary number or from the data's minimum value
    if (min_y >= 0 && !args.min_y && !args.use_data_y_min){
        min_y = 0;
    }

    //if a min_y or max_y have been set, use those instead
    min_y = args.min_y ? args.min_y : min_y;
    max_y = args.max_y ? args.max_y : max_y;

    if (args.y_scale_type != 'log') {
        // we are currently saying that if the min val > 0, set 0 as min y.
        if (min_y >= 0){
            args.y_axis_negative = false;
        } else {
            min_y = min_y  - (max_y * (args.inflator-1));
            args.y_axis_negative = true;
        }
    }

    max_y = max_y * args.inflator;
    if (!args.min_y && args.use_data_y_min){
        min_y = min_y / args.inflator;    
    }

    if (args.y_scale_type == 'log'){
        if (args.chart_type == 'histogram') {
            // log histogram plots should start just below 1
            // so that bins with single counts are visible
            min_y = 0.2;
        } else {
            if (min_y <= 0) {
                min_y = 1;
            }
        }

        args.scales.Y = d3.scale.log()
            .domain([min_y, max_y])
            .range([args.height - args.bottom - args.buffer, args.top])
            .clamp(true);
    } else {
        args.scales.Y = d3.scale.linear()
            .domain([min_y, max_y])
            .range([args.height - args.bottom - args.buffer, args.top]);
    }

    // used for ticks and such, and designed to be paired with log or linear.
    args.scales.Y_axis = d3.scale.linear()
        .domain([min_y, max_y])
        .range([args.height - args.bottom - args.buffer, args.top]);

    var yax_format;
    if (args.format == 'count') {
        yax_format = function(f) {
            if (f < 1.0) {
                // Don't scale tiny values.
                return args.yax_units + d3.round(f, args.decimals);
            } else {
                var pf = d3.formatPrefix(f);
{'fraction_non_alphanumeric': 0.14396529056008414, 'fraction_numerical': 0.01117538785169603, 'mean_word_length': 1.540748162992652, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3266021', 'n_tokens_mistral': 2737, 'n_tokens_neox': 2615, 'n_words': 586}