2

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?

2
  • have you tried referencing XPLot directly? Commented Oct 11, 2016 at 3:19
  • 1
    Well, it's a bit drastic but you can just replace the dll in Fslab's xplotly directory with the 1.4.2 version. Then it works. I haven't edited the other scripts. Commented Oct 11, 2016 at 3:59

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

I tried it as well and it is working with the latest version of XPlot library. But if I don't use the Fslab script, I get a lot of other errors. For example then I have to reference a lot of system packages (like System.Runtime) for my own. And I don't know why, because in the Fslab script there isn't any reference to these dlls.
@cpa those error are probably coming from other things you might be using from FSLab, like Deedle. Maybe this means that there is some incompatibility between Xplotly and FSLab. Do you need to use Plotly? Googlecharts in Xplot worked when I checked (from the FSLAB script).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.