コード例 #1
0
def plt_scatter1(data, param_dict, mode='object', output_path=None):
    #to_date(data,'%Y-%m-01')
    tooltips = create_tooltips(param_dict)

    title = "{} by {} (dot colors show {})".format(param_dict['y'].upper(),
                                                   param_dict['x'].upper(),
                                                   param_dict['color'].upper())

    try:
        color = param_dict['color']
    except KeyError:
        color = 'red'


#    p = figure(tooltips=tooltips)
#    p.scatter(data=data, x=param_dict['x'], y=param_dict['y'], color=color, title=title,
#            xlabel=param_dict['x'], ylabel=param_dict['y'],
#            plot_width=1000, plot_height=600, tooltips = tooltips,
#            legend_sort_field = 'color',
#            legend_sort_direction = 'ascending')
    p = Scatter(data=data,
                x=param_dict['x'],
                y=param_dict['y'],
                color=color,
                title=title,
                xlabel=param_dict['x'],
                ylabel=param_dict['y'],
                plot_width=1000,
                plot_height=600,
                tooltips=tooltips,
                legend_sort_field='color',
                legend_sort_direction='ascending')
    p.legend.background_fill_alpha = 0.8

    try:
        p.radius = param_dict['size']
    except KeyError:
        try:
            p.marker = param_dict['color']
        except KeyError:
            pass

    if type(data[0][param_dict['x']]) == str:
        x_rng = sort_axis(data, param_dict['x'], False, True)
        p.x_range = x_rng

    if type(data[0][param_dict['y']]) == str:
        y_rng = sort_axis(data, param_dict['y'], False, True)
        p.y_range = y_rng

    return do_output(p, mode, output_path)