I have a situation where I would like to create a Bokeh image_rgba graph with datetime axes. When I try to do this, something similar to the following code:
p1 = figure(x_axis_type = 'datetime', y_axis_type = 'datetime', x_range = [min(dates),max(dates)], y_range = [min(dates),max(dates)], x_axis_label = 'Purchase Date', y_axis_label = 'Sell Date', plot_width = 500, plot_height = 500) p1.image_rgba(image = [plotmatrix], x = [min(dates)], y = [min(dates)], dh = [max(dates)-min(dates)], dw = [max(dates)-min(dates)]) p1.grid.grid_line_color = None show(p1)
I get the following error:
TypeError: Timedelta('2139 days 00:00:00') is not JSON serializable
The plotmatrix variable is a numpy square matrix with a uint32 data type that has been packed with RGBA values based on the example in http://bokeh.pydata.org/en/latest/docs/gallery/image_rgba.html .
What is the recommended way to solve this problem. I understand that one option for me would be to include all times in a single time, enter the data based on the seconds, and then find some kind of axis label formatter to get the correct time information. But something in this decision seems too hacky to me.
Are there any suggestions to solve this problem?
source share