当前位置: 首页>>代码示例>>Python>>正文


Python models.DatetimeTickFormatter方法代码示例

本文整理汇总了Python中bokeh.models.DatetimeTickFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python models.DatetimeTickFormatter方法的具体用法?Python models.DatetimeTickFormatter怎么用?Python models.DatetimeTickFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models的用法示例。


在下文中一共展示了models.DatetimeTickFormatter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: style_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def style_plot(plot):
    # axis styling, legend styling
    plot.outline_line_color = None
    plot.axis.axis_label = None
    plot.axis.axis_line_color = None
    plot.axis.major_tick_line_color = None
    plot.axis.minor_tick_line_color = None
    plot.xgrid.grid_line_color = None
    plot.xaxis.formatter = DatetimeTickFormatter(hours=["%d %b %Y"],
                                                 days=["%d %b %Y"],
                                                 months=["%d %b %Y"],
                                                 years=["%d %b %Y"]
                                                 )
    #plot.legend.location = "top_left"
    #plot.legend.border_line_alpha = 0
    #plot.legend.background_fill_alpha = 0
    plot.title.text_font_size = "14pt"
    return plot 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:20,代码来源:bokeh_warnings_graphs.py

示例2: style_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def style_plot(plot):
    # axis styling, legend styling
    plot.outline_line_color = None
    plot.axis.axis_label = None
    plot.axis.axis_line_color = None
    plot.axis.major_tick_line_color = None
    plot.axis.minor_tick_line_color = None
    plot.xgrid.grid_line_color = None
    plot.xaxis.formatter = DatetimeTickFormatter(hours=["%d %b %Y"],
                                                 days=["%d %b %Y"],
                                                 months=["%d %b %Y"],
                                                 years=["%d %b %Y"]
                                                 )
    plot.legend.location = "top_left"
    plot.legend.border_line_alpha = 0
    plot.legend.background_fill_alpha = 0
    plot.title.text_font_size = "14pt"
    return plot 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:20,代码来源:bokeh_qc_graphs.py

示例3: style_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def style_plot(plot):
    plot.outline_line_color = None
    plot.axis.axis_label = None
    plot.axis.axis_line_color = None
    plot.axis.major_tick_line_color = None
    plot.axis.minor_tick_line_color = None
    plot.ygrid.grid_line_color = None
    plot.xgrid.grid_line_color = None
    plot.xaxis.formatter = DatetimeTickFormatter(hours=["%H:%M"],
                                                 days=["%H:%M"],
                                                 months=["%H:%M"],
                                                 years=["%H:%M"],
                                                 )

    plot.title.text_font_size = "14pt"
    return plot 
开发者ID:hdm-dt-fb,项目名称:rvt_model_services,代码行数:18,代码来源:bokeh_jobs_viz.py

示例4: build_pv_fig

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def build_pv_fig(data):
    # ========== themes & appearance ============= #
    LINE_COLOR = "#053061"
    LINE_WIDTH = 1.5
    TITLE = "PORTFOLIO VALUE OVER TIME" 

    # ========== data ============= #
    dates = np.array(data['date'], dtype=np.datetime64)
    pv_source = ColumnDataSource(data=dict(date=dates, portfolio_value=data['portfolio_value']))

    # ========== plot data points ============= #
    # x_range is the zoom in slider setup. Pls ensure both STK_1 and STK_2 have same length, else some issue
    pv_p = figure(plot_height=250, plot_width=600, title=TITLE, toolbar_location=None)
    pv_p.line('date', 'portfolio_value', source=pv_source, line_color = LINE_COLOR, line_width = LINE_WIDTH)
    pv_p.yaxis.axis_label = 'Portfolio Value'
    pv_p.xaxis[0].formatter = DatetimeTickFormatter()
    return pv_p 
开发者ID:wywongbd,项目名称:pairstrade-fyp-2019,代码行数:19,代码来源:layout.py

示例5: add_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def add_plot(stockStat, conf):
    p_list = []
    logging.info("############################", type(conf["dic"]))
    # 循环 多个line 信息。
    for key, val in enumerate(conf["dic"]):
        logging.info(key)
        logging.info(val)

        p1 = figure(width=1000, height=150, x_axis_type="datetime")
        # add renderers
        stockStat["date"] = pd.to_datetime(stockStat.index.values)
        # ["volume","volume_delta"]
        # 设置20个颜色循环,显示0 2 4 6 号序列。
        p1.line(stockStat["date"], stockStat[val], color=Category20[20][key * 2])

        # Set date format for x axis 格式化。
        p1.xaxis.formatter = DatetimeTickFormatter(
            hours=["%Y-%m-%d"], days=["%Y-%m-%d"],
            months=["%Y-%m-%d"], years=["%Y-%m-%d"])
        # p1.xaxis.major_label_orientation = radians(30) #可以旋转一个角度。

        p_list.append([p1])

    gp = gridplot(p_list)
    script, div = components(gp)
    return {
        "script": script,
        "div": div,
        "title": conf["title"],
        "desc": conf["desc"]
    } 
开发者ID:pythonstock,项目名称:stock,代码行数:33,代码来源:dataIndicatorsHandler.py

示例6: timeseries

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def timeseries():
    # Get data
    df = pd.read_csv('data/Land_Ocean_Monthly_Anomaly_Average.csv')
    df['datetime'] = pd.to_datetime(df['datetime'])
    df = df[['anomaly','datetime']]
    df['moving_average'] = pd.rolling_mean(df['anomaly'], 12)
    df = df.fillna(0)
    
    # List all the tools that you want in your plot separated by comas, all in one string.
    TOOLS="crosshair,pan,wheel_zoom,box_zoom,reset,hover,previewsave"

    # New figure
    t = figure(x_axis_type = "datetime", width=1000, height=200,tools=TOOLS)

    # Data processing
    # The hover tools doesn't render datetime appropriately. We'll need a string. 
    # We just want dates, remove time
    f = lambda x: str(x)[:7]
    df["datetime_s"]=df[["datetime"]].applymap(f)
    source = ColumnDataSource(df)

    # Create plot
    t.line('datetime', 'anomaly', color='lightgrey', legend='anom', source=source)
    t.line('datetime', 'moving_average', color='red', legend='avg', source=source, name="mva")

    # Style
    xformatter = DatetimeTickFormatter(formats=dict(months=["%b %Y"], years=["%Y"]))
    t.xaxis[0].formatter = xformatter
    t.xaxis.major_label_orientation = math.pi/4
    t.yaxis.axis_label = 'Anomaly(ºC)'
    t.legend.orientation = "bottom_right"
    t.grid.grid_line_alpha=0.2
    t.toolbar_location=None

    # Style hover tool
    hover = t.select(dict(type=HoverTool))
    hover.tooltips = """
        <div>
            <span style="font-size: 15px;">Anomaly</span>
            <span style="font-size: 17px;  color: red;">@anomaly</span>
        </div>
        <div>
            <span style="font-size: 15px;">Month</span>
            <span style="font-size: 10px; color: grey;">@datetime_s</span>
        </div>
        """
    hover.renderers = t.select("mva")

    # Show plot
    #show(t)
    return t

# Add title 
开发者ID:chdoig,项目名称:scipy2015-blaze-bokeh,代码行数:55,代码来源:viz2.py

示例7: timeseries

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def timeseries():
    # Get data
    df = pd.read_csv('data/Land_Ocean_Monthly_Anomaly_Average.csv')
    df['datetime'] = pd.to_datetime(df['datetime'])
    df = df[['anomaly','datetime']]
    df['moving_average'] = pd.rolling_mean(df['anomaly'], 12)
    df = df.fillna(0)
    
    # List all the tools that you want in your plot separated by comas, all in one string.
    TOOLS="crosshair,pan,wheel_zoom,box_zoom,reset,hover,previewsave"

    # New figure
    t = figure(x_axis_type = "datetime", width=1000, height=200,tools=TOOLS)

    # Data processing
    # The hover tools doesn't render datetime appropriately. We'll need a string. 
    # We just want dates, remove time
    f = lambda x: str(x)[:7]
    df["datetime_s"]=df[["datetime"]].applymap(f)
    source = ColumnDataSource(df)

    # Create plot
    t.line('datetime', 'anomaly', color='lightgrey', legend='anom', source=source)
    t.line('datetime', 'moving_average', color='red', legend='avg', source=source, name="mva")

    # Style
    xformatter = DatetimeTickFormatter(formats=dict(months=["%b %Y"], years=["%Y"]))
    t.xaxis[0].formatter = xformatter
    t.xaxis.major_label_orientation = math.pi/4
    t.yaxis.axis_label = 'Anomaly(ºC)'
    t.legend.orientation = "bottom_right"
    t.grid.grid_line_alpha=0.2
    t.toolbar_location=None

    # Style hover tool
    hover = t.select(dict(type=HoverTool))
    hover.tooltips = """
        <div>
            <span style="font-size: 15px;">Anomaly</span>
            <span style="font-size: 17px;  color: red;">@anomaly</span>
        </div>
        <div>
            <span style="font-size: 15px;">Month</span>
            <span style="font-size: 10px; color: grey;">@datetime_s</span>
        </div>
        """
    hover.renderers = t.select("mva")

    # Show plot
    #show(t)
    return t 
开发者ID:chdoig,项目名称:scipy2015-blaze-bokeh,代码行数:53,代码来源:viz.py

示例8: build_normalized_price_fig

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def build_normalized_price_fig(data):
    # ========== themes & appearance ============= #
    STK_1_LINE_COLOR = "#053061"
    STK_2_LINE_COLOR = "#67001f"
    STK_1_LINE_WIDTH = 1.5
    STK_2_LINE_WIDTH = 1.5
    WINDOW_SIZE = 10
    TITLE = "PRICE OF X vs Y" 
    HEIGHT = 250
    SLIDER_HEIGHT = 150
    WIDTH = 600

    # ========== data ============= #
    # use sample data from ib-data folder
    dates = np.array(data['date'], dtype=np.datetime64)
    STK_1_source = ColumnDataSource(data=dict(date=dates, close=data['data0']))
    STK_2_source = ColumnDataSource(data=dict(date=dates, close=data['data1']))

    # ========== plot data points ============= #
    # x_range is the zoom in slider setup. Pls ensure both STK_1 and STK_2 have same length, else some issue
    normp = figure(plot_height=HEIGHT, 
                   plot_width=WIDTH, 
                   x_range=(dates[-WINDOW_SIZE], dates[-1]), 
                   title=TITLE, 
                   toolbar_location=None)

    normp.line('date', 'close', source=STK_1_source, line_color = STK_1_LINE_COLOR, line_width = STK_1_LINE_WIDTH)
    normp.line('date', 'close', source=STK_2_source, line_color = STK_2_LINE_COLOR, line_width = STK_2_LINE_WIDTH)
    normp.yaxis.axis_label = 'Price'

    normp.xaxis[0].formatter = DatetimeTickFormatter()


    # ========== RANGE SELECT TOOL ============= #

    select = figure(title="Drag the middle and edges of the selection box to change the range above",
                    plot_height=SLIDER_HEIGHT, plot_width=WIDTH, y_range=normp.y_range,
                    x_axis_type="datetime", y_axis_type=None,
                    tools="", toolbar_location=None, background_fill_color="#efefef")

    range_tool = RangeTool(x_range=normp.x_range)
    range_tool.overlay.fill_color = "navy"
    range_tool.overlay.fill_alpha = 0.2

    select.line('date', 'close', source=STK_1_source, line_color = STK_1_LINE_COLOR, line_width = STK_1_LINE_WIDTH)
    select.line('date', 'close', source=STK_2_source, line_color = STK_2_LINE_COLOR, line_width = STK_2_LINE_WIDTH)
    select.ygrid.grid_line_color = None
    select.add_tools(range_tool)
    select.toolbar.active_multi = range_tool

    return column(normp, select) 
开发者ID:wywongbd,项目名称:pairstrade-fyp-2019,代码行数:53,代码来源:layout.py

示例9: build_spread_fig

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DatetimeTickFormatter [as 别名]
def build_spread_fig(data, action_df):
    palette = ["#053061", "#67001f"]
    LINE_WIDTH = 1.5
    LINE_COLOR = palette[-1]
    TITLE = "RULE BASED SPREAD TRADING"
    HEIGHT = 250
    WIDTH = 600

    # ========== data ============= #
    # TODO: get action_source array
    # TODO: map actions to colours so can map to palette[i]
    dates = np.array(data['date'], dtype=np.datetime64)
    spread_source = ColumnDataSource(data=dict(date=dates, spread=data['spread']))
    action_source = ColumnDataSource(action_df)
    # action_source['colors'] = [palette[i] x for x in action_source['actions']]

    # ========== figure INTERACTION properties ============= #
    TOOLS = "hover,pan,wheel_zoom,box_zoom,reset,save"

    spread_p = figure(tools=TOOLS, toolbar_location=None, plot_height=HEIGHT, plot_width=WIDTH, title=TITLE)
    # spread_p.background_fill_color = "#dddddd"
    spread_p.xaxis.axis_label = "Backtest Period"
    spread_p.yaxis.axis_label = "Spread"
    # spread_p.grid.grid_line_color = "white"


    # ========== plot data points ============= #
    # plot the POINT coords of the ACTIONS
    circles = spread_p.circle("date", "spread", size=12, source=action_source, fill_alpha=0.8)

    circles_hover = bkm.HoverTool(renderers=[circles], tooltips = [
        ("Action", "@latest_trade_action"),                    
        ("Stock Bought", "@buy_stk"),
        ("Bought Amount", "@buy_amt"),
        ("Stock Sold", "@sell_stk"),
        ("Sold Amount", "@sell_amt")
        ])

    spread_p.add_tools(circles_hover)

    # plot the spread over time
    spread_p.line('date', 'spread', source=spread_source, line_color = LINE_COLOR, line_width = LINE_WIDTH)
    spread_p.xaxis[0].formatter = DatetimeTickFormatter()
    
    return spread_p 
开发者ID:wywongbd,项目名称:pairstrade-fyp-2019,代码行数:47,代码来源:layout.py


注:本文中的bokeh.models.DatetimeTickFormatter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。