2016-09-23 18 views
2

bokehで複数行のプロットタイトルを作成するには...同じ質問https://github.com/bokeh/bokeh/issues/994
と同じ質問はまだ解決されていますか?bokehで複数行のプロットタイトルを作成する方法は?

import bokeh.plotting as plt 

plt.output_file("test.html") 
plt.text(x=[1,2,3], y = [0,0,0], text=['hello\nworld!', 'hello\nworld!', 'hello\nworld!'], angle = 0) 
plt.show() 

さらに、タイトルテキスト文字列でリッチテキストを使用できますか?

答えて

-1

あなたはこれであなたのプロットに簡単なタイトルを追加することができます。

from bokeh.plotting import figure, show, output_file 

output_file("test.html") 
p = figure(title="Your title") 
p.text(x=[1,2,3], y = [0,0,0], text=['hello\nworld!', 'hello\nworld!', 'hello\nworld!'], angle = 0) 
show(p) 

enter image description here


補遺ここ

することはあなたのためのパンダのデータフレームをプロットするための実施例でありますジュピターノートにコピー/ペーストする。エレガントでもピジョンソニックでもありません。私は様々なSOの投稿からずっと前にそれを得ました。申し訳ありませんが、私はもう何を覚えていないので、私はそれらを引用することはできません。ボケの最近のバージョンで

コード

# coding: utf-8 
from bokeh.plotting import figure, show 
from bokeh.io import output_notebook 
import pandas as pd 
import numpy as np 


# Create some data 
np_arr = np.array([[1,1,1], [2,2,2], [3,3,3], [4,4,4]]) 
pd_df = pd.DataFrame(data=np_arr) 
pd_df 

# Convert for multi-line plotting 
data = [row[1].as_matrix() for row in pd_df.iterrows()] 
num_lines = len(pd_df) 
cols = [pd_df.columns.values] * num_lines 
data 

# Init bokeh output for jupyter notebook - Adjust this to your needs 
output_notebook() 

# Plot 
p = figure(plot_width=600, plot_height=300) 
p.multi_line(xs=cols, ys=data) 
show(p) 

プロット

enter image description here

+1

質問には、複数行のプロットタイトルが必要です。 – PJW

0

、ラベルとテキストのグリフは、テキストに改行を受け入れることができ、そして予想通りこれらがレンダリングされます。複数行タイトルの場合は、必要な行ごとに明示的にTitle注釈を追加する必要があります。ここでは完全な例である:

生成
from bokeh.io import output_file, show 
from bokeh.models import Title 
from bokeh.plotting import figure 

output_file("test.html") 

p = figure(x_range=(0, 5)) 
p.text(x=[1,2,3], y = [0,0,0], text=['hello\nworld!', 'hello\nworld!', 'hello\nworld!'], angle = 0) 

p.add_layout(Title(text="Sub-Title", text_font_style="italic"), 'above') 
p.add_layout(Title(text="Title", text_font_size="16pt"), 'above') 

show(p) 

:基礎となるHTMLキャンバスがリッチ受け付けませんので、あなたは、ボケが公開している標準の「テキストプロパティ」に限定されている

enter image description here

注意をテキスト。そのようなものが必要な場合は、可能な場合があります。custom extension

関連する問題