簡體   English   中英

Python Plotly explress 線 - 如何改變線下的顏色

[英]Python Plotly explress line - how to change the color under the line

我有以下代碼

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))

結果在這里輸入圖像描述

如何在線下添加顏色,類似的東西在這里輸入圖片描述

我相信您正在尋找 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()

我刪除了第二條跟蹤的代碼,因為看起來您只想 plot 一行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM