【问题标题】:Python Plotly explress line - how to change the color under the linePython Plotly 表达线 - 如何改变线下的颜色
【发布时间】:2021-01-28 22:35:27
【问题描述】:

我有以下代码

daily=pd.read_csv
y_columns= ['1 mo', '2 mo', '3 mo', '6 mo', '1 yr', '2 yr', '3 yr', '5 yr',
   '7 yr', '10 yr', '20 yr', '30 yr']
fig = px.line(daily, x='Date', title='XX')

fig.update_layout(title_x=0.5, yaxis=dict(tick0 = 0.2, dtick = 2.5))

结果 enter image description here

如何在线条下制作颜色,类似的东西 enter image description here

【问题讨论】:

标签: python-3.x colors plotly-python


【解决方案1】:

我相信您正在寻找 Plotly 的 Filled Area Plots。如果您向下滚动一点,您会找到基本叠加面积图的示例代码:

import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[0, 2, 3, 5], fill='tozeroy')) # fill down to xaxis

fig.show()

我删除了第二个跟踪的代码,因为您似乎只想绘制一行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 2021-10-31
    • 2018-11-07
    • 2013-10-07
    • 2021-03-10
    • 2020-06-26
    相关资源
    最近更新 更多