简体   繁体   English

更改 python 散景 PreText() 的颜色

[英]change color of python bokeh PreText()

Is there a way to change the font or the color of有没有办法改变字体或颜色

bokeh.models.widgets.markups.PreText bokeh.models.widgets.markups.PreText

from bokeh.models.widgets import PreText
from bokeh.plotting import show

mytext = PreText()
mytext.text = "Text in black"
show(mytext)

Bokeh markups are mapped to HTML elements, therefore you can bind style to it through the keyword style .散景标记映射到 HTML 元素,因此您可以通过关键字style将样式绑定到它。 Like this:像这样:

mytext = PreText(text="Text in black", style={'color': 'black'})

Also notice that the PreText maps to the <pre> tag which is used for pre formatted text, normally used to display code, for example.另请注意, PreText映射到<pre>标记,该标记用于预格式化文本,例如,通常用于显示代码。 Depending on what you want do display, Paragraph would be more appropriate.根据您想要显示的内容,段落会更合适。

You may check the documentation here and also a similar question of using Bokeh and applying style.您可以在此处查看文档以及使用散景和应用样式的类似问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM