
- Bokeh 教程
- Bokeh - 首頁
- Bokeh - 簡介
- Bokeh - 環境設定
- Bokeh - 入門
- Bokeh - Jupyter Notebook
- Bokeh - 基本概念
- Bokeh - 使用 Glyph 繪製圖形
- Bokeh - 面積圖
- Bokeh - 圓形 Glyph
- Bokeh - 矩形、橢圓和多邊形
- Bokeh - 扇形和弧形
- Bokeh - 專用曲線
- Bokeh - 設定範圍
- Bokeh - 座標軸
- Bokeh - 註釋和圖例
- Bokeh - Pandas
- Bokeh - ColumnDataSource
- Bokeh - 資料過濾
- Bokeh - 佈局
- Bokeh - 繪圖工具
- Bokeh - 樣式化視覺屬性
- Bokeh - 自定義圖例
- Bokeh - 新增小部件
- Bokeh - 伺服器
- Bokeh - 使用 Bokeh 子命令
- Bokeh - 匯出圖形
- Bokeh - 嵌入圖形和應用程式
- Bokeh - 擴充套件 Bokeh
- Bokeh - WebGL
- Bokeh - 使用 JavaScript 開發
- Bokeh 有用資源
- Bokeh - 快速指南
- Bokeh - 有用資源
- Bokeh - 討論
Bokeh - 自定義圖例
圖形中的各種 Glyph 可以透過圖例屬性來識別,預設情況下圖例顯示為圖形區域右上角的標籤。可以透過以下屬性自定義此圖例:
1 | legend.label_text_font | 將預設標籤字型更改為指定的字型名稱。 | |
2 | legend.label_text_font_size | 以磅為單位的字型大小。 | |
3 | legend.location | 在指定位置設定標籤。 | |
4 | legend.title | 設定圖例標籤的標題。 | |
5 | legend.orientation | 設定為水平(預設)或垂直。 | |
6 | legend.clicking_policy | 指定單擊圖例時應發生什麼:hide:隱藏對應於圖例的 Glyph;mute:靜音對應於圖例的 Glyph。 |
示例
圖例自定義的示例程式碼如下:
from bokeh.plotting import figure, output_file, show import math x2 = list(range(1,11)) y4 = [math.pow(i,2) for i in x2] y2 = [math.log10(pow(10,i)) for i in x2] fig = figure(y_axis_type = 'log') fig.circle(x2, y2,size = 5, color = 'blue', legend = 'blue circle') fig.line(x2,y4, line_width = 2, line_color = 'red', legend = 'red line') fig.legend.location = 'top_left' fig.legend.title = 'Legend Title' fig.legend.title_text_font = 'Arial' fig.legend.title_text_font_size = '20pt' show(fig)
輸出

廣告