Example #1
0
def generate_box_plot(sdf, colors):
	"""
	The colors were hacked in here!
	If the columns are not as in the order below in the final output, the colors will be wrong!
	"""
	from bokeh.charts import BoxPlot
	from bokeh.charts import color
	box_colors = [colors["HGST"], colors["Hitachi"], colors["Seagate"], colors["Toshiba"], colors["Western Digital"]]
	#palette = box_colors
	#print(box_colors)
	plot = BoxPlot(sdf, values='failure_rate', label='manufacturer',
            title="Failure Rate by Manufacturer", outliers=False, 
            color=color(columns=['manufacturer'], palette=box_colors), legend=False, tools=None)

	plot.yaxis.axis_label = "Failure Rate"
	plot.xaxis.axis_line_width = 2
	plot.yaxis.axis_line_width = 2
	plot.title.text_font_size = '16pt'
	plot.xaxis.axis_label_text_font_size = "14pt"
	plot.xaxis.major_label_text_font_size = "14pt"
	plot.yaxis.axis_label_text_font_size = "14pt"
	plot.yaxis.major_label_text_font_size = "14pt"
	plot.y_range = Range1d(0, 15)
	plot.ygrid.grid_line_color = None
	plot.toolbar.logo = None
	plot.outline_line_width = 0
	plot.outline_line_color = "white"
	return plot
Example #2
0
def plot_status_per_host(dataframe):
    for i,row in dataframe.iterrows():
        dataframe.loc[i,'exec_host'] = row['exec_host'].split('-0-')[1]
    mycolors = ['green','red','blue','orange','yellow','purple','black']
    p = Bar(dataframe, label='exec_host',values='exec_host', agg='count', group='status',
        title="Status per Exec Host", legend='top_right',color=color('status', palette=mycolors),
        height=500,width=1000)

    return p
Example #3
0
def plot_credit_grade_data(df):

    plot = Bar(df,
               'grade',
               xlabel='Credit Grade Category',
               ylabel='Count of Borrowers',
               title='Credit Grade of Borrowers',
               legend='top_right',
               color=color(columns='grade'))

    script, div = components(plot)
    return script, div
Example #4
0
def bokeh_high_level_scatter(ag2):
    pal = [
        '#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f',
        '#bf5b17'
    ]
    tooltips = [("Cat", "@Cat"), ("Dog", "@Dog"), ("Livestock", "@Livestock"),
                ("ZipCode", "@ZipCode")]
    s = Scatter(ag2,
                x='Cat',
                y='Dog',
                color=color('Livestock', palette=pal),
                tooltips=tooltips)
    output_file('bokeh_high_scatter.html')
    show(s)
Example #5
0
def plot_state_data(df):

    plot = Bar(df,
               'addr_state',
               legend=False,
               xlabel='By State',
               ylabel='Count of Borrowers',
               title='Borrowers by State',
               color=color(columns='addr_state'),
               width=1200,
               height=500)

    script, div = components(plot)
    return script, div
Example #6
0
def plot_loan_status(df):

    df_filtered = df[(df['loan_status'] == 'Fully Paid') |
                     (df['loan_status'] == 'Charged Off')]
    plot = Bar(df,
               'loan_status',
               legend=False,
               ylabel='Count of Borrowers',
               xlabel='Status of loans',
               title='Loan Status of borrowers',
               color=color(columns='loan_status'),
               width=400,
               height=600)

    script, div = components(plot)
    return script, div