【发布时间】:2021-11-14 21:39:20
【问题描述】:
我已经制作了一个 Plotly Express 折线图:
fig = px.line(pmt_old_and_new, x="day", y="value", color="type")
fig.show()
但是它在图表上没有 0 作为起点。如何添加它?我希望轴有 0
【问题讨论】:
标签: python python-3.x plot plotly plotly-express
我已经制作了一个 Plotly Express 折线图:
fig = px.line(pmt_old_and_new, x="day", y="value", color="type")
fig.show()
但是它在图表上没有 0 作为起点。如何添加它?我希望轴有 0
【问题讨论】:
标签: python python-3.x plot plotly plotly-express
定义轴的范围:
import numpy as np
import pandas as pd
import plotly.express as px
df = pd.concat([pd.DataFrame({"day":range(50),"avg_spending":np.random.randint(1,17,50)}).assign(type=type) for type in ["one","two"]])
fig = px.line(df, x="day", y="avg_spending", color="type")
fig.update_layout(yaxis={"dtick":1,"range":[0,17]},margin={"t":0,"b":0},height=500)
【讨论】: