I am relatively new to python and I am using bokeh to create a html file that plots some timeseries data.
I would like to format the x-axis ticks as "DD/MM HH:SS". I am writing a simplified version of the code:
from bokeh.plotting import figure, output_file, save, show
from bokeh.models import DatetimeTickFormatter
import datetime as dt
t=[dt.datetime(2017, 1, 9, 16, 14, 10),dt.datetime(2017, 1, 9, 16, 15, 20)]
Temp=[200,210]
output_file("Burner SPC test.html")
p1=figure(title="Tip1 TC", x_axis_label="Time", y_axis_label="Temp Diff", x_axis_type="datetime")
p1.line(t,Temp)
p1.xaxis.formatter=DatetimeTickFormatter(formats=dict(
days=["%??"],
months=["%??"],
hours=["%???"],
minutes=["%???"])) #not sure how to format here to get the desired output
show(p1)
Any help is highly appreciated. Thanks in advance.
I solved it using "%m/%d %H:%M"
for all the fields: months, days, hours, minutes:
p1.xaxis.formatter=DatetimeTickFormatter(formats=dict(
days=["%m/%d %H:%M"],
months=["%m/%d %H:%M"],
hours=["%m/%d %H:%M"],
minutes=["%m/%d %H:%M"]
))
Initially I was trying to use "%m"
for months, "%d"
for days, "%H"
for hours and "%M"
for minutes but since I want the same format across all those scales, they all need to be configured the same.