Exemplo n.º 1
0
def init_mention_plot():
    cprint('%s: init @ mentios barcharts...' % TAG, 'yellow', attrs=['bold'])
    global mention_count
    global mention_barplot
    mention_count = count_mentions()
    y = []
    mentions = []
    for (mention, freq) in mention_count:
        y.append(freq)
        mentions.append(mention)
    x = np.arange(len(mentions))
    source = ColumnDataSource(dict(
        x=x,
        top=y,
    ))
    glyph = VBar(x='x', top='top', bottom=0, width=0.85, fill_color='#ff7f0e')
    mention_barplot.add_glyph(source, glyph)

    xaxis = LinearAxis()
    xaxis.ticker = x
    xaxis.major_label_overrides = {
        i: mention
        for i, mention in enumerate(mentions)
    }
    mention_barplot.add_layout(xaxis, 'below')
    mention_barplot.xaxis.major_label_orientation = +np.pi / 2

    yaxis = LinearAxis()
    yaxis.axis_label = 'Overall number of @ mentions'
    yaxis.axis_label_text_font_size = '14pt'
    yaxis.ticker = np.linspace(0, max(y), 11, dtype=np.int)[1:]
    mention_barplot.add_layout(yaxis, 'left')

    mention_barplot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
    mention_barplot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
Exemplo n.º 2
0
def init_user_plot():
    cprint('%s: init @ users barcharts...' % TAG, 'yellow', attrs=['bold'])
    global user_count
    global user_barplot
    user_count = count_users()
    y = []
    users = []
    for (user, freq) in user_count.items():
        y.append(freq)
        users.append(user)
    x = np.arange(len(users))

    wlist = []
    for user in users:
        prefixes = ['@' + user]
        for prefix, freq in sorted(user_tweet_freq[user].items(),
                                   key=lambda kv: kv[1],
                                   reverse=True)[:10]:
            prefixes.append(' %s:%d' % (prefix, freq))
        wlist.append(list(prefixes))

    source = ColumnDataSource(dict(x=x, top=y, wlist=wlist))
    glyph = VBar(x='x', top='top', bottom=0, width=0.85, fill_color='#1f77b4')
    user_barplot.add_glyph(source, glyph)

    xaxis = LinearAxis()
    xaxis.ticker = x
    xaxis.major_label_overrides = {
        i: '@' + user
        for i, user in enumerate(users)
    }
    #xaxis.major_label_standoff = -35
    user_barplot.add_layout(xaxis, 'below')
    user_barplot.xaxis.major_label_orientation = +np.pi / 2

    yaxis = LinearAxis()
    yaxis.axis_label = 'Overall number of tweets per @'
    yaxis.axis_label_text_font_size = '14pt'
    yaxis.ticker = np.linspace(0, max(y), 11, dtype=np.int)[1:]
    user_barplot.add_layout(yaxis, 'left')

    user_barplot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
    user_barplot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
Exemplo n.º 3
0
top = Figure(tools=tools, title=None, x_range=day_range,
             **figure_style_kws)
top.line('day', 'S', source=source,
         line_color=colors[0], line_width=3, line_cap='round')
top.y_range = Range1d(0., 40.)
top.yaxis.axis_label = "Salinity (g/kg)"
top.xaxis.axis_label_text_font_size = label_fontsize
top.yaxis.axis_label_text_font_size = label_fontsize

# overlay volume level chart to salinity
tc = "MediumBlue"  # tide color
tide_range = Range1d(start=0, end=15)
tide_axis = LinearAxis(y_range_name="Z")
tide_axis.axis_label = "Tidal Height (m)"
tide_axis.axis_label_text_color = tc
tide_axis.axis_label_text_font_size = label_fontsize
tide_axis.major_tick_line_color = tc
tide_axis.major_label_text_color = tc
tide_axis.minor_tick_line_alpha = 0.

top.extra_y_ranges = {"Z": tide_range}
# top.line('day', 'Z', source=source,
         # line_color=tc, line_width=2, line_cap='round')
top.add_layout(tide_axis, "right")
top.line('day', 'Z', source=source,
         line_color=tc, line_width=2, line_cap='round',
         y_range_name="Z")

mid = Figure(title=None, x_range=top.x_range,
             toolbar_location=None, **figure_style_kws)
mid.line('day', 'N', source=source,