Plotly:如何将 ticktext 设置为斜体?
Plotly: How to set ticktext to italics?
我想将轴上文本的文本样式更改为斜体,即。滴答字体
下面是相关的一段脚本:
代码:
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()
剧情:
如何在不更改任何其他字体的情况下将轴上的文本 apple, ball, cat
的文本样式更改为斜体 属性
Plotly 允许一些 HTML styling 直接在字符串输入到轴标签上。您可以使用列表理解 thing = ['<i>'+elem+'</i>' for elem in thing]
轻松地将 thing = ["apple","ball","cat"]
更改为 ['<i>apple</i>', '<i>ball</i>', '<i>cat</i>']
剧情:
代码:
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()
我想将轴上文本的文本样式更改为斜体,即。滴答字体
下面是相关的一段脚本:
代码:
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()
剧情:
如何在不更改任何其他字体的情况下将轴上的文本 apple, ball, cat
的文本样式更改为斜体 属性
Plotly 允许一些 HTML styling 直接在字符串输入到轴标签上。您可以使用列表理解 thing = ['<i>'+elem+'</i>' for elem in thing]
thing = ["apple","ball","cat"]
更改为 ['<i>apple</i>', '<i>ball</i>', '<i>cat</i>']
剧情:
代码:
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()