ボケプロット上のx軸は、2016-01-01 12:00:00
のような時間ではなく、five seconds
のような時間を表します。私のBokeh x軸上のチックを適切にレンダリングする方法はありますか?ボケ0.12.6、you can use PrintfTickFormatter
にBokeh x_axis_typeの期間は?
答えて
:以下のプロットで0ms
の繰り返しから分かるようにx_axis_type='datetime'
を設定することは、非常に正しいことをしません。
from bokeh.plotting import figure, output_file, show
from bokeh.models import PrintfTickFormatter
output_file('output.html')
p = figure(plot_width=400, plot_height=400) p.line(x, y, size=1)
# must be applied to the 1st element, not the axis itself
p.xaxis[0].formatter = PrintfTickFormatter(format="%sms")
show(p)
あなたも、それも直線軸で動作します、x_axis_type='datetime'
を設定する必要はありません。
編集:Bokehが現時点で処理するには洗練されていないため、単位のカスタム書式設定(ms/s/min、you have to use FuncTickFormatter
)を適用します。それを0.12.6として使用するには2通りの方法があります。
最初に、transpilerを使用して、Python関数をFlexx(pip install flexx
)経由でJavascriptコードに変換します。これはすべてをPythonの構文の下に保ちますが、追加の依存関係を必要とします。
from bokeh.plotting import figure, output_file, show
from bokeh.models import FuncTickFormatter
output_file('output.html')
p = figure(plot_width=400, plot_height=400) p.line(x, y, size=1)
# custom formatter function
def custom_formatter():
units = [
('min', 60000.0),
('s', 1000.0),
('ms', 1.0),
]
for u in units:
if tick >= u[1]:
return '{}{}'.format(tick/u[1], u[0])
# must be applied to the 1st element, not the axis itself
p.xaxis[0].formatter = FuncTickFormatter.from_py_func(custom_formatter)
show(p)
最後に、実際のJavascriptコードを文字列として書き込み、パラメータとしてフォーマッタに渡すことで、 Bokehはそれをネイティブに行います。あなたはクライアント環境を制御できないので、純粋なバニラのJavascript以外のものを使用しないでください。
from bokeh.plotting import figure, output_file, show
from bokeh.models import FuncTickFormatter
output_file('output.html')
p = figure(plot_width=400, plot_height=400) p.line(x, y, size=1)
units = [
('min', 60000.0),
('s', 1000.0),
('ms', 1.0),
]
# must be applied to the 1st element, not the axis itself
p.xaxis[0].formatter = FuncTickFormatter(code=""" var units = {'min':
60000.0, 's': 1000.0, 'ms': 1.0}; for (u in units) {
if (tick >= units[u]) {
return (tick/units[u] + u);
} } """)
show(p)
私はそれが少し面倒だとわかりましたが、私はアプリケーションのために軸を固定しました。私はtick
という変数をハードコードする必要があることを知っています。うまくいけば、Bokehは近い将来より良いソリューションを提供します。
これは素晴らしいです。ミルク秒から数秒または数分に移動するときなど、日時単位を処理する方法に関する考えはありますか? – MRocklin
@MRocklinはい、私のアプリケーションにも同様の問題がありました(ただし、日/月/年を扱います)。私が使用したソリューションを追加するための質問を編集しましたが、私が望んでいたよりもはるかに多くでした。 –
- 1. Bokeh(0.12.1)Bokehを使用してプログラムでbokeh serve(Pythonのみ)
- 2. 'bokeh serve'(bokeh 0.12.0)を使用してプロットを動的に追加/削除する
- 3. PythonでBokehとプロットの間にスパンまたはカーソルをリンク
- 4. Bokehチャートのヒストグラムには時間がかかります
- 5. Bokehアプリケーションのスロットル
- 6. Bokehのタイムスチャート
- 7. bokeh DataTableの幅
- 8. Bokehサーバホワイトリスト
- 9. Bokeh Barプロット|
- 10. Python/Bokeh - FuncTickFormatter
- 11. 期間はCATransform3DMakeTranslation
- 12. BokehウィジェットCSS
- 13. Bokehプロットタグレンダリングの問題
- 14. Python bokehの逆軸
- 15. bokehのJinja2変数
- 16. Bokeh時系列プロット注釈が1時間オフです
- 17. Python Bokeh - blending
- 18. GMapPlotアニメーション/ Python/Bokeh
- 19. Bokeh DatePickerエラー
- 20. Bokeh画像セクション
- 21. bokehサーバホストホワイトリスト追加
- 22. オーディオ期間は0.0
- 23. のstd ::クロノ:カスタム期間は
- 24. Firebirdのグループは、期間
- 25. モバイルアナリティクスのイベント期間は?
- 26. Excelは2時間との間の計算期間は
- 27. bokehのcolumnDataSourceの目的
- 28. Bokeh resize - plot overshadows widgets
- 29. Bokehアプリケーション開発ワークフロー
- 30. Python Bokeh:内部サーバーエラー
"おそらく、カスタムビジュアルフォーマッタを作成するべきです"(@bigreddotからgitter経由で)。おそらく誰かが答えとして模範デモンストレーションを提出する時間があります。 –
この回答には例があります:http://stackoverflow.com/a/37182788/1736679 – Efren