私はBokehを使用しており、FuncTickFormatter
を使用して軸をフォーマットするのに苦労しています。Python/Bokeh - FuncTickFormatter
特に私はFuncTickFormatter.from_py_func
機能を使用しています。
私の下のコード例では、結果は出ません(エラーメッセージも表示されません)。
from bokeh.models import ColumnDataSource,Label, FuncTickFormatter,DatetimeTickFormatter,NumeralTickFormatter, Select, FixedTicker, Slider,TableColumn,DatePicker, DataTable, TextInput, HoverTool,Range1d,BoxZoomTool, ResetTool
from bokeh.plotting import figure, output_file, show, curdoc
from bokeh.layouts import row, column, widgetbox, layout
from bokeh.io import output_notebook, push_notebook, show
output_notebook()
x = np.arange(10)
y = [random.uniform(0,5000) for el in x]
xfactors = list("abcdefghi")
yrange = Range1d(0,5000)
p = figure(x_range = xfactors, y_range = yrange,y_minor_ticks = 10)
p.circle(x,y, size = 14, line_color = "grey" , fill_color = "lightblue", fill_alpha = 0.2)
def ticker():
a = '{:0,.0f}'.format(tick).replace(",", "X").replace(".", ",").replace("X", ".")
return a
# If I comment below line out, code is running just fine
p.yaxis.formatter = FuncTickFormatter.from_py_func(ticker)
show(p)
私がFuncTickFormatterラインをコメントアウトすると、コードは正常に動作しています。また、定義済みの関数ticker
は、このコードの外で使用すると機能します。
私が間違っていることについてのアドバイスは非常に役に立ちます。
ありがとうございます!
今、 'tick 'は' ticker'の内部スコープ内またはメインのスコープ内でプログラム内のどこにも定義されていません。 'tick 'は' ticker'の入力引数でしょうか? – tmwilson26
はい、わかっています。しかし、ドキュメントを理解する方法は、定義する必要はありません([Bokeh](http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#functickformatter)を参照してください。明らかに私は、しかし、完全に正しいものを得るには... – FredMaster
おそらく、私のバージョンでは 'ValueError:Function" funcは "引数を1つしか持てませんが、0が与えられました"つまり、 'format'メソッドの代わりに'% 'を使用して文字列を再フォーマットしない限り、プロットは空白です。 – tmwilson26