F# 中 xplot/plotly 的连续误差带

continuous error bands with xplot/plotly, in F#

我正在尝试制作这样的图表:

如此处页面所述:https://plotly.com/python/continuous-error-bars/

相关的python代码是:

go.Scatter(
    x=x+x[::-1], # x, then x reversed
    y=y_upper+y_lower[::-1], # upper, then lower reversed
    fill='toself'
)

但我不太确定如何使 F# 等效于:

y=y_upper+y_lower[::-1]

和xplot/plotly

如何绘制这样的图形?

实际上,您可以使用 Plotly.NET!

这是一个完整的片段,将在 .NET Interactive 中重现图表。

#r "nuget: Plotly.NET.Interactive, 2.0.0-beta9"

open Plotly.NET

let x = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
let y = [1; 2; 7; 4; 5; 6; 7; 8; 9; 10]
let y_upper = [2; 3; 8; 5; 6; 7; 8; 9; 10; 11]
let y_lower = [0; 1; 5; 3; 4; 5; 6; 7; 8; 9]

Chart.Range(
    x,
    y,
    y_upper,
    y_lower,
    StyleParam.Mode.Lines,
    Color="rgb(0,100,80)",
    RangeColor="rgba(0,100,80,0.2)")

文档中的渲染出于某种原因拉伸了 x 轴,尽管我在跟踪本身中看不到这一点。

有关详细信息,请参阅 range charts

至于 y=y_upper+y_lower[::-1] 位,这只是 F# 中的列表追加,因此它将是:

y_upper @ (y_upper |> List.rev)

但是,如果您使用 Plotly.NET。

,至少在最初看来,这可能不是必需的