Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 绘图:如何设置文本格式(下划线、粗体、斜体)_Python_Text_Formatting_Plotly_Underline - Fatal编程技术网

Python 绘图:如何设置文本格式(下划线、粗体、斜体)

Python 绘图:如何设置文本格式(下划线、粗体、斜体),python,text,formatting,plotly,underline,Python,Text,Formatting,Plotly,Underline,在使用注释时,我会尝试在文本中绘出下划线。 我使用 import plotly.graph_objects as go g = go.FigureWidget(make_subplots(rows=1,cols=1)) g.update_layout(annotations=[dict(text='my text')]) #plus any other parameters 是否有一个选项(在注释目录中,可能?)来添加下划线文本 谢谢 使用HTML标记的子集来设置文本格式,如粗体'和斜体'。唉

在使用注释时,我会尝试在文本中绘出下划线。 我使用

import plotly.graph_objects as go
g = go.FigureWidget(make_subplots(rows=1,cols=1))
g.update_layout(annotations=[dict(text='my text')]) #plus any other parameters
是否有一个选项(在注释目录中,可能?)来添加下划线文本


谢谢

使用HTML标记的子集来设置文本格式,如粗体
'
和斜体
'
。唉,
目前似乎没有包括在内。但是包含linebreak,因此您可以像这样做一些工作:

string = "These are orange"
myText = string+'<br>'+ '-'*len(string)

这里有一个移帧并不能解决你的问题,但可能会使它消失:下划线文本在传统字体中是不寻常的:试着在实际的、专业排版的书籍或报纸中找到下划线文本。您将很难找到示例(在web排版中,通常会保留超链接)。因此,考虑你是否真的想用下划线来调整你的文本。它看起来不专业。它是一个人物传奇的头像,我认为它适合。一般来说,我同意你的考虑,肯定是一个不错的部分解决方案,不适合我的申请,但是我认为如果没有更好的解决方案,就把它当作一个“解决方案”来接受。appearing@MaxS谢谢你的反馈!我也尝试了其他一些方法,但结果令人沮丧。如果你感兴趣的话,我会把它们包括在内。也许你能找到必要的调整。就像上面在对问题的评论中提到的,我想用它作为图例的标题,但解决方案不合适,因为换行符的空间太大,也许这也可以更改,但之后你开始为变通办法实施变通办法。。。
import plotly.graph_objects as go
animals=['giraffes', 'orangutans', 'monkeys']

fig = go.Figure([go.Bar(x=animals, y=[20, 14, 23])])

string = "These are orange"
myText = string+'<br>'+ '-'*len(string)

fig.update_layout(annotations=[dict(x='orangutans',y = 15, text=myText, font=dict(family='Courier New, monospace'))])
fig.show()
  text
 |                  Sets the text associated with this annotation.
 |                  Plotly uses a subset of HTML tags to do things
 |                  like newline (<br>), bold (<b></b>), italics
 |                  (<i></i>), hyperlinks (<a href='...'></a>).
 |                  Tags <em>, <sup>, <sub> <span> are also
 |                  supported.