Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

Python Plotly explress line - how to change the color under the line

I have the following code

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

with the result enter image description here

How to make color under the line, something like that enter image description here

question from:https://stackoverflow.com/questions/65946188/python-plotly-explress-line-how-to-change-the-color-under-the-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I believe you're looking for Plotly's Filled Area Plots. If you scroll down a little, you'll find the sample code for a Basic Overlaid Area Chart:

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

I removed the code for the second trace since it looks like you only want to plot a single line.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...