-
博克-定制图例
博克-定制图例
原文:https://www.geeksforgeeks.org/bokeh-customising-legends/
图表的图例反映了图表 Y 轴中显示的数据。在博克,传说对应于字形。本文介绍了如何自定义 bokeh 剧情中出现的传说。
我们可以自定义图例的几个属性,如位置、颜色、线条颜色、字体大小、字体样式的线条宽度。我们可以使用带有所需属性名称的图例属性来修改它。
语法: legend.property_name=value
参数:
这里属性名可以采用以下值
- 位置
- 标题
- label_text_font
- 标签 _ 文本 _ 字体 _ 样式
- label_text_color
- 边框 _ 线条 _ 宽度
- 边框 _ 线条 _ 颜色
- 边框 _ 线条 _alpha
- 背景 _ 填充 _ 颜色
- 背景 _ 填充 _alpha
接近
- 导入模块
- 画一个普通的图
- 相应地定制
- 显示图
例 1:
Python 3
# import module
from bokeh.plotting import figure, show
# create data
currentList = [1, 2, 3, 4, 5]
List1 = [i*2 for i in currentList]
List2 = [i+2 for i in currentList]
# plot data
plots = figure(title=" your Legend Customization")
line = plots.line(
currentList,
List1,
legend_label="Arrays .",
line_color="blue",
line_width=2
)
circle = plots.circle(
currentList,
List2,
legend_label="List",
fill_color="black",
fill_alpha=0.4,
line_color="blue",
size=30,
)
# display legend in top right corner
plots.legend.location = "top_right"
# give title to legend
plots.legend.title = "Your observations"
# customize legend appearance
plots.legend.label_text_font = "times"
plots.legend.label_text_font_style = "italic"
plots.legend.label_text_color = "red"
# customize border and background of legend
plots.legend.border_line_width = 15
plots.legend.border_line_color = "pink"
plots.legend.border_line_alpha = 0.5
plots.legend.background_fill_color = "orange"
plots.legend.background_fill_alpha = 0.3
# display plot
show(plots)
输出:
例 2 :
Python 3
# import module
from bokeh.plotting import figure, show
# create data
currentList = [1, 2, 3, 4, 5]
List1 = [i*2 for i in currentList]
List2 = [i+2 for i in currentList]
# plot data
plots = figure(title="Legend Customization")
line = plots.line(currentList,
List1,
legend_label="Arrays .",
line_color="blue",
line_width=2
)
circle = plots.circle(
currentList,
List2,
legend_label="List",
fill_color="black",
fill_alpha=0.5,
line_color="blue",
size=40,
)
# display legend in top left corner
plots.legend.location = "top_left"
#give title to legend
plots.legend.title = "Observation of plot"
#customize legend appearance
plots.legend.label_text_font = "times"
plots.legend.label_text_font_style = "bold"
plots.legend.label_text_color = "black"
# customize border and background of legend
plots.legend.border_line_width = 9
plots.legend.border_line_color = "green"
plots.legend.border_line_alpha = 0.7
plots.legend.background_fill_color = "magenta"
plots.legend.background_fill_alpha = 0.2
show(plots)
输出:
例 3 :
Python 3
# import module
from bokeh.plotting import figure, show
# create data
currentList = [1, 2, 3, 4, 5]
List1 = [i*2 for i in currentList]
List2 = [i+2 for i in currentList]
# plot data
plots = figure(title="Legend Customization")
line = plots.line(currentList,
List1,
legend_label="Arrays .",
line_color="blue",
line_width=2
)
circle = plots.circle(
currentList,
List2,
legend_label="List",
fill_color="black",
fill_alpha=0.5,
line_color="blue",
size=50,
)
# display legend in top right corner
plots.legend.location = "top_center"
# give title to legend
plots.legend.title = " Your Observations "
# customize legend appearance
plots.legend.label_text_font = "times"
plots.legend.label_text_font_style = "normal"
plots.legend.label_text_color = "red"
# customize border and background of legend
plots.legend.border_line_width = 3
plots.legend.border_line_color = "grey"
plots.legend.border_line_alpha = 0.8
plots.legend.background_fill_color = "orange"
plots.legend.background_fill_alpha = 0.2
show(plots)
输出
版权属于:月萌API www.moonapi.com,转载请注明出处
本文链接:https://www.moonapi.com/news/11951.html
最新更新
Objective-C语法之代码块(block)的使用
VB.NET eBook
Add-in and Automation Development In VB.NET 2003 (F
Add-in and Automation Development In VB.NET 2003 (8
Add-in and Automation Development in VB.NET 2003 (6
Add-in and Automation Development In VB.NET 2003 (5
AddIn Automation Development In VB.NET 2003 (4)
AddIn And Automation Development In VB.NET 2003 (2)
Addin and Automation Development In VB.NET 2003 (3)
AddIn And Automation Development In VB.NET 2003 (1)
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
SQL Server -- 解决存储过程传入参数作为s
武装你的WEBAPI-OData入门
武装你的WEBAPI-OData便捷查询
武装你的WEBAPI-OData分页查询
武装你的WEBAPI-OData资源更新Delta
5. 武装你的WEBAPI-OData使用Endpoint 05-09
武装你的WEBAPI-OData之API版本管理
武装你的WEBAPI-OData常见问题
武装你的WEBAPI-OData聚合查询
OData WebAPI实践-OData与EDM
OData WebAPI实践-Non-EDM模式