2016-10-27 11 views
0

私はBokeh 0.11.1を使用しており、pip install --upgrade bokehは最新のバージョンを使用していると報告しています。bokeh.charts軸ラベルのサイズを変更するにはどうすればいいですか?

bokeh.plottingを使用しているがbokehの図表を使用していない場合は、bokeh x軸のテキストサイズのパラメータを変更する方法を決定できます。以下のコードは、Jupyterノートブックで実行されている場合、非常にタイトなx軸ラベルを表示します。私はフォントを小さくしたいと思っています - これを達成するためのヒント?

import pandas as pd 
data = pd.read_csv("https://raw.githubusercontent.com/pm0kjp/datastore/master/river_data.csv") 

import bokeh.charts 
import bokeh.plotting 
bokeh.plotting.output_notebook() 

tooltips=[ 
    ('Water Site ', '$x'), 
    ('Average of Enterococcus Count ', '$y') 
] 

p = bokeh.charts.Scatter(data, x='Site', y='EnteroCount', 
     title="Swimming Holes By Average Enterococcus Count", ylabel="Enterococcus Count", tooltips=tooltips) 
p.width=1000 
bokeh.charts.show(p) 

ドキュメントは、私は単に p.yaxis.axis_label_text_font_size = "8pt"を追加することができますことを示唆しているが、私はそれを行う場合、私は、エラー AttributeError: 'Chart' object has no attribute 'yaxis'を取得します。

答えて

3

axis labelsのスタイル設定方法を含め、styling visual properties専用のユーザーガイドセクション全体があります。

ここ
p.yaxis.axis_label_text_font_size = "8pt" 

0.12.3のための完全な実施例である:

In [1]: import bokeh 

In [2]: bokeh.__version__ 
Out[2]: '0.12.3' 

In [3]: import pandas as pd 
    ...: data = pd.read_csv("https://raw.githubusercontent.com/pm0kjp/datastore/master/river_data.csv") 
    ...: 

In [4]: import bokeh.charts 

In [5]: tooltips=[ 
    ...:  ('Water Site ', '$x'), 
    ...:  ('Average of Enterococcus Count ', '$y') 
    ...: ] 
    ...: p = bokeh.charts.Scatter(data, x='Site', y='EnteroCount', 
    ...:   title="Swimming Holes By Average Enterococcus Count", ylabel="Enterococcus Count", tooltips=tooltips) 
    ...: p.width=1000 
    ...: 

In [6]: p.yaxis.axis_label_text_font_size = "4pt" 

In [7]: bokeh.charts.output_file("/tmp/chart.html") 

In [8]: bokeh.charts.show(p) 

プロパティを設定すると、いずれの場合も同じであり、両方の低レベルオブジェクトの同じセットに解決bokeh.chartsbokeh.plottingによって作成されたプロット以来そして、ここでの結果は、小さなy軸ラベルで、次のとおりです。

enter image description here


あなたには、いくつかの理由でバージョン0.12に更新できない場合は、行うことができます:

In [12]: from bokeh.models import Axis 

In [13]: p.select(type=Axis) 
Out[13]: 
[LinearAxis(id='54b21a9f-22e0-4f7a-b809-8d4f755a444e', ...), 
CategoricalAxis(id='b52e7b2c-2b18-4578-be42-4fbfba17af60', ...)] 

は、あなたが彼らのaxis_label_text_font_sizeプロパティを設定することで直接修正することができ、すべてのAxesオブジェクトのネタを取得します。しかし、どの軸がxであり、どれがyであるのか把握しなければならないでしょう。

+0

私は 'AttributeError: 'Chart'オブジェクトには属性 'yaxis'がありません。私はすでにそれを試みたことを示すために質問を編集します! – Joy

+1

あなたはかなり古いバージョンのBokehを持っています。これは、あなたが助けを求めるときに使用しているソフトウェアのバージョンを明記することが常に重要な理由です。私の最初の提案は単に新しいバージョンに更新することです。 – bigreddot

+0

OK、私はpipがインストールできる最新のbokehを使用していますが、まだ問題が表示されています。私は質問を編集しました。 – Joy

関連する問題