Vertical line on time series chart

This is probably a trivial question but I cannot figure it out. I have a line chart with x_axis_type=“datetime” and I want to draw a vertical line at specific points in time where certain events are occurring.

I don’t see any example like this in the gallery but I thought ray might do the trick.

I’m using code similar to the below, with data being a pandas data frame with data[0] being a pandas.tslib.Timestamp, and data[1] being a float.

    figure(plot_height = plotHeight,

       plot_width = plotWidth,

       x_axis_type = "datetime",

       tools="pan,wheel_zoom,box_zoom,reset,previewsave")

    hold()

    line(

        data[0],                                            # x coordinates

        data[1],                                            # y coordinates

        plot_width=plotWidth,                               # width

        plot_height=plotHeight,                             # height

        color="blue",                                       # set a color for the line

        legend=label,                                       # attach a legend label

    )        

    ray(

        event,

        0,

        90,

        500,

        color = "red")

    show()

Unfortunately when I use a pandas.tslib.Timestamp for the x coordinate of a ray the library crashes:

/Library/Python/2.7/site-packages/bokeh/plotting_helpers.pyc in _match_data_params(argnames, glyphclass, datasource, serversource, args, kwargs)
    139             glyph_val = {'field' : var, 'units' : units}
    140         else:
--> 141             raise RuntimeError("Unexpected column type: %s" % type(val))
    142         glyph_params[var] = glyph_val
    143     return glyph_params

RuntimeError: Unexpected column type: <class 'pandas.tslib.Timestamp'>

Is it possible to draw a vertical line in a time series chart with Bokeh, and if so what is the correct approach?


Thanks!
Jason

Apparently there is some problem with the encoder and Timestamp. Can you try converting that column to something else (e.g., python or numpy datetime) and see if that works?

···

On Jan 30, 2015, at 12:39 PM, [email protected] wrote:

This is probably a trivial question but I cannot figure it out. I have a line chart with x_axis_type="datetime" and I want to draw a vertical line at specific points in time where certain events are occurring.

I don't see any example like this in the gallery but I thought ray might do the trick.

I'm using code similar to the below, with data being a pandas data frame with data[0] being a pandas.tslib.Timestamp, and data[1] being a float.

        figure(plot_height = plotHeight,
           plot_width = plotWidth,
           x_axis_type = "datetime",
           tools="pan,wheel_zoom,box_zoom,reset,previewsave")
        hold()
        line(
            data[0], # x coordinates
            data[1], # y coordinates
            plot_width=plotWidth, # width
            plot_height=plotHeight, # height
            color="blue", # set a color for the line
            legend=label, # attach a legend label
        )
        ray(
            event,
            0,
            90,
            500,
            color = "red")
        show()

Unfortunately when I use a pandas.tslib.Timestamp for the x coordinate of a ray the library crashes:

/Library/Python/2.7/site-packages/bokeh/plotting_helpers.pyc in _match_data_params(argnames, glyphclass, datasource, serversource, args, kwargs)
    139 glyph_val = {'field' : var, 'units' : units}
    140 else:
--> 141 raise RuntimeError("Unexpected column type: %s" % type(val))
    142 glyph_params[var] = glyph_val
    143 return glyph_params

RuntimeError: Unexpected column type: <class 'pandas.tslib.Timestamp'>

Is it possible to draw a vertical line in a time series chart with Bokeh, and if so what is the correct approach?

Thanks!
Jason

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ee08e8b1-dfb1-4f22-9f7f-7693e158c203%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.