2017-08-16 1 views
0

Ich möchte ein vbar-Diagramm mit Bokeh, wo x-Achse dauert Datum und y-Achse nimmt kategorische Werte.kategorische y-Achse und datetime x-Achse mit Bokeh vbar plot

Anfangs habe ich versucht, Kreis Handlung wie folgt:

import pandas as pd 
from datetime import datetime 
from dateutil.parser import parse  
from bokeh.plotting import figure, show, output_notebook  
from bokeh.models.ranges import FactorRange 

x = pd.Series(['2017/1/1', '2017/1/2', '2017/1/3', '2017/1/4']).map(lambda x: parse(x)) 
y = ["a", "b", "c", "a"] 

p = figure(x_axis_type='datetime', y_range=list(set(y)), plot_width=400, plot_height=200) 
p.circle(x, y, size=10, line_color="blue", line_width=1) 
show(p) 

Es Ausnahme der Tatsache, sieht gut aus, dass es nicht in bar Form ist.

enter image description here

Als nächstes habe ich versucht, den folgenden Code, aber keine Plots angezeigt:

x = pd.Series(['2017/1/1', '2017/1/2', '2017/1/3', '2017/1/4']).map(lambda x: parse(x)) 
y = ["a", "b", "c", "a"] 

p = figure(x_axis_type='datetime', y_range=list(set(y)), plot_width=400, plot_height=200) 
p.vbar(x=x, bottom=0, top=y, width=0.1, color="blue") 

show(p) 

enter image description here

Antwort

2

Genau in dieses Problem selbst lief. Bei einer Datetime-X-Achse muss die Vbar-Breite sehr groß sein, da die Datetime-Achse eine Auflösung von Millisekunden haben muss.

Breite = 3600000 (3,6 Millionen) ergibt Balkenbreiten von beispielsweise 1 Stunde.

+0

Aha, ich habe es! Ich danke dir sehr! – Royalblue