问题
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.
I am using FSLab and there is XPlot.Plotly 1.3.1 included.
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
I'm getting this error: "The field, constructor or member 'Plot' is not defined.
Do I am missing something?
回答1:
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
Now, this will plot the charts in the browser. I believe you can bind it to WPF or winforms as well.
Edit
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
.
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
来源:https://stackoverflow.com/questions/39962034/plotting-data-of-deedle-data-frame-with-xplot-plotly