Plotly:如何在绘图内/轴右侧设置 y 轴刻度标签?
Plotly: How to set y-axis ticklabels inside the plot / to the right of the axis?
像这样的情节:
如何在图中或 y 轴右侧设置 y 轴刻度标签?
代码
import plotly.express as px
df = px.data.stocks(indexed=True)-1
fig = px.bar(df, x=df.index, y="GOOG")
fig.show()
过去几年,SO 上以多种形式询问了此功能 - 通常作为更详细问题的补充。在 Plotly version 4.14
之后,这可以很容易地完成,例如:
ticklabelposition="inside top"
剧情:
完整代码:
import plotly.express as px
df = px.data.stocks(indexed=True)-1
fig = px.bar(df, x=df.index, y="GOOG")
fig.update_yaxes(ticklabelposition="inside top", title=None)
fig.show()
像这样的情节:
如何在图中或 y 轴右侧设置 y 轴刻度标签?
代码
import plotly.express as px
df = px.data.stocks(indexed=True)-1
fig = px.bar(df, x=df.index, y="GOOG")
fig.show()
过去几年,SO 上以多种形式询问了此功能 - 通常作为更详细问题的补充。在 Plotly version 4.14
之后,这可以很容易地完成,例如:
ticklabelposition="inside top"
剧情:
完整代码:
import plotly.express as px
df = px.data.stocks(indexed=True)-1
fig = px.bar(df, x=df.index, y="GOOG")
fig.update_yaxes(ticklabelposition="inside top", title=None)
fig.show()