예제 #1
0
def bokeh_precursor_int(LogPrecursorInt):
    p = figure(title='Intensity of PrecursorInt')
    output_notebook()
    hist, edges = np.histogram(LogPrecursorInt, density=True, bins=50)
    p.quad(top=hist,
           bottom=0,
           left=edges[:-1],
           right=edges[1:],
           fill_color="#036564",
           line_color="#033649")
    lpi_median = np.median(LogPrecursorInt)
    p.line([lpi_median, lpi_median], [min(hist), max(hist)], color="#ee3333")
    p.text(text=["<- median: {0:.2f}".format(lpi_median)],
           x=lpi_median,
           y=max(hist) * .9)
    p.xaxis.axis_label = 'log10 intensity'
    p.yaxis.axis_label = 'Count'
    return p
예제 #2
0
def bokeh_median_frag_int_per_scan(fragment_ions):
    median_int = list(map(np.median, fragment_ions))
    p = figure(title='median fragment intensity per scan')
    output_notebook()
    hist, edges = np.histogram(median_int, density=True, bins=50)
    p.quad(top=hist,
           bottom=0,
           left=edges[:-1],
           right=edges[1:],
           fill_color="#036564",
           line_color="#033649")

    fc_median = np.median(median_int)
    p.line([fc_median, fc_median], [min(hist), max(hist)], color="#ee3333")
    p.text(text=["<- median: {0:.2f}".format(fc_median)],
           x=fc_median,
           y=max(hist) * .9)
    p.xaxis.axis_label = 'Ion Intensity'
    p.yaxis.axis_label = 'Count'
    return p
예제 #3
0
def plot_Deff(bins_num, PEG, Particle_Type, Surfactant, Size_Range, ZP_Range):
    """
    This function plots the particles depending on the selected particle
    properties input. It has been customized to allow interactive input from
    the function below. The list of variables were created manually and would
    have to be changed for a different data set.
    The unittests for plot_Deff alone don't make sense, because it is only
    called upon with the interact function and UI input.
    """
    # Here size_center, size_tick, and zp_tick are set because these values
    # determine the Size_Range and ZP_Range categories. They must be manually
    # changed here, as well as in interact_plot_deff below.
    size_center = 100
    size_tick = 10
    zp_tick = 5
    data = working_data(size_center, size_tick, zp_tick)
    data2 = data
    sizes = set_size_range(size_center, size_tick)
    zp = set_zp_range(zp_tick)
    list_vars_Size_Range = list()
    list_vars_ZP_Range = list()
    # Here the lists for size range and zp range are taken from the dataframes
    # created from the set size and zp range functions.
    for x in range(0, len(sizes)):
        list_vars_Size_Range.insert(x, sizes['Size_Range'][x])
    list_vars_Size_Range.insert(0, 'All')
    for x in range(0, len(zp)):
        list_vars_ZP_Range.insert(x, zp['ZP_Range'][x])
    list_vars_ZP_Range.insert(0, 'All')
    list_vars_Surfactant = ['All', 'UP', 'P80', 'F68', '5CHA', '2CHA',
                            '0.5CHA']
    list_vars_Particle_Type = ['All', '58k', '45k', '15k']
    if PEG == 'No':
        data2 = data[data.PEG == 'No']
    if PEG == 'Yes':
        data2 = data[data.PEG == 'Yes']
    data = data2
    data2 = pd.DataFrame()
    for x in range(0, len(list_vars_Surfactant)):
        for y in range(0, len(Surfactant)):
            if Surfactant[y] == list_vars_Surfactant[x]:
                data2 = data2.append(data[data.Surfactant == Surfactant[y]])
    if Surfactant[0] == 'All':
        data2 = data
    data = data2
    data2 = pd.DataFrame()
    for x in range(0, len(list_vars_Particle_Type)):
        for y in range(0, len(Particle_Type)):
            if Particle_Type[y] == list_vars_Particle_Type[x]:
                data2 = data2.append(data[data.Particle_Type ==
                                          Particle_Type[y]])
    if Particle_Type[0] == 'All':
        data2 = data
    data = data2
    data2 = pd.DataFrame()
    for x in range(0, len(list_vars_Size_Range)):
        for y in range(0, len(Size_Range)):
            if Size_Range[y] == list_vars_Size_Range[x]:
                data2 = data2.append(data[data.Size_Range == Size_Range[y]])
    if Size_Range[0] == 'All':
        data2 = data
    data = data2
    data2 = pd.DataFrame()
    for x in range(0, len(list_vars_ZP_Range)):
        for y in range(0, len(ZP_Range)):
            if ZP_Range[y] == list_vars_ZP_Range[x]:
                data2 = data2.append(data[data.ZP_Range == ZP_Range[y]])
    if ZP_Range[0] == 'All':
        data2 = data
    data = data2
    # An if statement is present to prevent the function from attempting to
    # plot if no particles are selected to prevent encountering an error.
    if data.empty is True:
        print('No particles meet the selected parameters. Please broaden '
              'your filters.')
    else:
        defaults.width = 1000
        p = Histogram(
                data, values='Deff', color='Particle', bins=bins_num,
                title="Deff Distribution of Particles", legend='top_right')
        output_notebook()
        show(p)
예제 #4
0
# coding: utf-8

# In[2]:

from bokeh.sampledata.autompg import autompg as df
from bokeh.charts import Histogram, output_notebook, show, hplot
# print df
output_notebook()


# In[16]:

hist = Histogram(df, values='mpg', title="Auto MPG Histogram", width=400)
hist2 = Histogram(df, values='displ', label='cyl', color='cyl', legend='top_right',
                  title="MPG Histogram by Cylinder Count", width=400)

show(hplot(hist, hist2))


# In[5]:

# Modules needed from Bokeh.
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import LinearAxis, Range1d

# Seting the params for the first figure.
s1 = figure(x_axis_type="datetime",plot_width=1000,
           plot_height=600)
예제 #5
0
# ### Do the Zodiacs Influence Aircraft Accidents?
#
# The Chinese Zodiac is a 12 year cycle, with each year being represented by a different animal from the Chinese lunar calendar. According to ancient superstition, you will have bad luck during the Zodiac year in which you were born.
#
# But does this bad luck influence aircraft fatalities? Maybe if you're superstitious, but over the years they have fallen into a fairly tight distribution.
#
# - Deadliest Zodiac since 1908: **Ox** - 10,134 Deaths
# - Safest Zodiac since 1908: **Rabbit** - 6,956 Deaths

# In[ ]:

import numpy as np
import pandas as pd
import datetime
from bokeh.charts import Scatter, Bar, show, output_notebook
output_notebook()
data = pd.read_csv('../input/3-Airplane_Crashes_Since_1908.txt', sep=',')
data.sample()

# In[ ]:


# Return a bunch of tuples with the Zodiac and its Start/End Dates
def chinese_zodaics():
    start_date = pd.to_datetime("2/2/1908")
    end_date = pd.to_datetime("7/1/2009")
    animals = [
        'Monkey', 'Rooster', 'Dog', 'Pig', 'Rat', 'Ox', 'Tiger', 'Rabbit',
        'Dragon', 'Snake', 'Horse', 'Goat'
    ]
    zodiacs = []