python - Plotly:如何将刻度文本设置为斜体?

标签 python fonts plotly

我想将轴上的文本样式更改为斜体,即。刻度字体

下面是相关的脚本片段:

代码:

import plotly.graph_objs as go

# figure input
thing = ["apple","ball","cat"]
name = [1,2,3]
t = dict(family="Univers LT Std", size=14,color='black')

# figure setup
fig = go.Figure(data=[go.Scatter(x=name, y=thing, type='scatter')])

fig.update_layout(yaxis=dict(title="<i>Deviation from median (%)</i>",
                             titlefont=t, tickfont=t,gridcolor='rgba(255, 255, 255, 0.2)', showgrid=True))
fig.show()   

plotly :

enter image description here

如何在不更改任何其他字体属性的情况下将轴上的文本 apple, ball, cat 的文本样式更改为斜体

最佳答案

Plotly 允许一些 HTML styling直接在轴标签的字符串输入上。并且您可以轻松更改thing = ["apple","ball","cat"]['<i>apple</i>', '<i>ball</i>', '<i>cat</i>']使用列表理解 thing = ['<i>'+elem+'</i>' for elem in thing]

plotly :

enter image description here

代码:

import plotly.graph_objs as go

thing = ["apple","ball","cat"]
thing = ['<i>'+elem+'</i>' for elem in thing]

name = [1,2,3]
t = dict(family="Univers LT Std", size=14,color='black')

fig = go.Figure(data=[go.Scatter(x=name, y=thing, type='scatter')])

fig.update_layout(yaxis=dict(title="<i>Deviation from median (%)</i>",
                             titlefont=t, tickfont=t,gridcolor='rgba(255, 255, 255, 0.2)', showgrid=True))
fig.show()    

关于python - Plotly:如何将刻度文本设置为斜体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58878364/

相关文章:

python - Google App Engine,上传图像

android - 自由手绘字体识别

python - Plotly Plot surface 3D 不显示

r - 在条形图中的主网格线之间添加网格线

r - 在 R/ggplot 中没有得到 geom_text

python - 为什么在 chrome 浏览器上无法使用 Seeking 属性??但它可以在 IE 上运行

python - 我怎样才能得到我的python脚本的路径?

python : UDP Socket How to Waiting Client Side Reply Bytes String

CSS Div/Box 字体问题

java - 不同机器上的字体及其大小