情节 - 填充三行之间的区域 - 如何删除此深色阴影

发布于 2025-01-30 01:20:24 字数 1062 浏览 2 评论 0原文

fig = go.Figure(layout_yaxis_range=[0,10])

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['25 Percentile'],
    name = '25th Percentile',
    mode='text',
    line=dict(color='blue'),
    fill='tonext',
    fillcolor='grey',
    connectgaps=False
))

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['Median'],
    name = 'Median',
    mode='lines',
    line=dict(color='green'),
    fill='tonexty',
    fillcolor='#eaecee',
    connectgaps=False
))

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['75 Percentile'],
    name = '75th Percentile',
    mode='text',
    line=dict(color='blue'),
    fill='tonexty',
    fillcolor='#eaecee',
    connectgaps=False
))

fig.update_layout(template='plotly_white')
fig.show()

我试图填补三行之间的区域,但无法摆脱这种黑暗的阴影。 我试图通过将其更改为所有可用值来确保填充=''参数是正确的,但不确定哪个参数可以工作。

如何删除这个黑暗的阴影?

谢谢!

fig = go.Figure(layout_yaxis_range=[0,10])

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['25 Percentile'],
    name = '25th Percentile',
    mode='text',
    line=dict(color='blue'),
    fill='tonext',
    fillcolor='grey',
    connectgaps=False
))

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['Median'],
    name = 'Median',
    mode='lines',
    line=dict(color='green'),
    fill='tonexty',
    fillcolor='#eaecee',
    connectgaps=False
))

fig.add_traces(go.Scatter(
    x=df['date'],
    y=df['75 Percentile'],
    name = '75th Percentile',
    mode='text',
    line=dict(color='blue'),
    fill='tonexty',
    fillcolor='#eaecee',
    connectgaps=False
))

fig.update_layout(template='plotly_white')
fig.show()

I'm trying to fill area between three lines But can't get rid of this dark shadows.
I have tried to make sure fill='' parameter is right by changing it to all available values but not sure which one will work.

How do i remove this dark shadows?

Thanks!
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2025-02-06 01:20:24
  • 已经模拟数据以重新生产,
  • 您的代码有两个问题
    • 两个轨迹被定义为mode =“ text”已更改为mode =“ lines”
    • 仅想要fill =“ tonexty”百分位轨迹
import plotly.graph_objects as go
import pandas as pd
import numpy as np

df = pd.DataFrame({"date": pd.date_range("30-mar-2022", "15-may-2022")}).assign(
    val=lambda d: np.random.randint(1, 10, len(d))
)

df = df.join(
    df["val"]
    .rolling(5)
    .agg(["median", lambda w: np.percentile(w, 25), lambda w: np.percentile(w, 75)])
).dropna()
df.columns = ["date", "val", "Median", "25 Percentile", "75 Percentile"]


fig = go.Figure(layout_yaxis_range=[0, 10])

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["25 Percentile"],
        name="25th Percentile",
        mode="lines",
        line=dict(color="blue"),
        # fill='tonext',
        # fillcolor='grey',
        connectgaps=False,
    )
)

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["Median"],
        name="Median",
        mode="lines",
        line=dict(color="green"),
        fill="tonexty",
        fillcolor="#eaecee",
        connectgaps=False,
    )
)

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["75 Percentile"],
        name="75th Percentile",
        mode="lines",
        line=dict(color="blue"),
        fill="tonexty",
        fillcolor="#eaecee",
        connectgaps=False,
    )
)

fig.update_layout(template="plotly_white")
fig.show()

a href =“ https://i.sstatic.net/hvy3e.png” rel =“ nofollow noreferrer”>

  • have simulated data to be able to re-produce
  • there were two issues with you code
    • two traces were defined as mode="text" have changed to mode="lines"
    • only want fill="tonexty" on percentile traces
import plotly.graph_objects as go
import pandas as pd
import numpy as np

df = pd.DataFrame({"date": pd.date_range("30-mar-2022", "15-may-2022")}).assign(
    val=lambda d: np.random.randint(1, 10, len(d))
)

df = df.join(
    df["val"]
    .rolling(5)
    .agg(["median", lambda w: np.percentile(w, 25), lambda w: np.percentile(w, 75)])
).dropna()
df.columns = ["date", "val", "Median", "25 Percentile", "75 Percentile"]


fig = go.Figure(layout_yaxis_range=[0, 10])

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["25 Percentile"],
        name="25th Percentile",
        mode="lines",
        line=dict(color="blue"),
        # fill='tonext',
        # fillcolor='grey',
        connectgaps=False,
    )
)

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["Median"],
        name="Median",
        mode="lines",
        line=dict(color="green"),
        fill="tonexty",
        fillcolor="#eaecee",
        connectgaps=False,
    )
)

fig.add_traces(
    go.Scatter(
        x=df["date"],
        y=df["75 Percentile"],
        name="75th Percentile",
        mode="lines",
        line=dict(color="blue"),
        fill="tonexty",
        fillcolor="#eaecee",
        connectgaps=False,
    )
)

fig.update_layout(template="plotly_white")
fig.show()

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文