本文介绍了用Xplot绘制幼年数据帧的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Deedle数据帧,其中DateTime值作为键,两列中包含数据.现在,我想用来自Plotly的散点图绘制第1列的数据.

I have a Deedle data frame with DateTime values as key and two columns with data. Now I want to plot the data of column 1 with a Scatter chart from Plotly.

我正在使用FSLab,其中包含XPlot.Plotly 1.3.1.

I am using FSLab and there is XPlot.Plotly 1.3.1 included.

但是我不能使用Plotly:

But I can't use Plotly:

open XPlot.Plotly.Graph
open XPlot.Plotly
open XPlot.Plotly.HTML

let dataFrame = ...

Scatter(
  x = dataFrame.ColumnKeys,
  y = dataFrame.GetColumn("col1")
)
|> Chart.Plot
|> Chart.Show

我收到此错误:未定义字段,构造函数或成员'Plot'.

I'm getting this error: "The field, constructor or member 'Plot' is not defined.

我缺少什么吗?

推荐答案

不确定XPlot的最新版本是什么,但是我在nuget中得到1.4.2.因此,为简单起见,这次我避免了所有的FSLab魔术:

Not sure what is the latest version of XPlot but I get 1.4.2 in nuget. So, to make things simple I avoided all the FSLab magic this time:

//#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
#r @"..\packages\XPlot.Plotly.1.4.2\lib\net45\XPlot.Plotly.dll"
#r @"..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll"
open XPlot.Plotly
open XPlot.Plotly.Graph

let layout = Layout(title = "Basic Bar Chart")

["giraffes", 20; "orangutans", 14; "monkeys", 23]
|> Chart.Bar
|> Chart.WithLayout layout
|> Chart.WithHeight 500
|> Chart.WithWidth 700
|> Chart.Show


let lineTrace1 =
    Scatter(
        x = [1; 2; 3; 4],
        y = [10; 15; 13; 17],
        mode = "markers"
    )

lineTrace1 |> Chart.Plot   |> Chart.Show

现在,这将在浏览器中绘制图表.我相信您也可以将其绑定到WPF或Winforms.

Now, this will plot the charts in the browser. I believe you can bind it to WPF or winforms as well.

修改

因为这对您有用,但您仍然需要FSLab,简单的解决方法是替换...\FSLAB\packages\XPlot.Plotly\lib\net45中的XPlot.Plotly.dll和xml文件.

As this works for you, but you still need FSLab, the easy way out is to replace the XPlot.Plotly.dll and xml file in ...\FSLAB\packages\XPlot.Plotly\lib\net45.

然后您可以调用XPlot.Plotly,而无需直接引用dll.

Then you can call XPlot.Plotly without the need of referencing directly the dll.

#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
open XPlot.Plotly
open XPlot.Plotly.Graph
open XPlot.Plotly.Html

let layout = Layout(title = "Basic Bar Chart")
["giraffes", 20; "orangutans", 14; "monkeys", 23]
|> Chart.Bar
|> Chart.WithLayout layout
|> Chart.WithHeight 500
|> Chart.WithWidth 700
|> Chart.Show

这篇关于用Xplot绘制幼年数据帧的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 17:46