f# - 在 F# 中使用 xplot/plotly 的连续误差带
问题描述
我正在尝试制作这样的图表:
如此处页面中所述: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 轴,即使我在跟踪本身中看不到它。
有关更多信息,请参阅范围图。
至于y=y_upper+y_lower[::-1]
位,这只是 F# 中的一个列表追加,所以它是:
y_upper @ (y_upper |> List.rev)
但是,至少在最初,如果您使用 Plotly.NET,这似乎是不必要的。
推荐阅读
- android - 无法使用 cordova-plugin-facebook4 和 phonegap-plugin-barcodescanner 构建 cordova 应用程序
- java - Launch4J 创建 exe 文件导致 VirusTotal 误报?
- javascript - JS Array.indexOf 返回错误的值
- typo3 - TYPO3:为特定站点激活的扩展程序
- java - “变量”无法解析为变量
- python - 正则表达式:匹配除 unicode 字母之外的所有内容
- python - 我们可以在 python 的 os.system() 中使用 \ 作为转义序列吗
- node.js - 将nodejs永久安装/添加到(Jenkins)docker镜像中
- java - 当从图库中选择图像时“文档不断停止”错误显示
- javascript - 如何转义 html 标签并在 jquery 中显示?