fsprojects / IfSharp

F# for Jupyter Notebooks
Other
441 stars 71 forks source link

Unable to find FSCharting.Gtk.fsx #115

Closed Gabology closed 7 years ago

Gabology commented 7 years ago

Steps to reproduce, in a new cell evaluate, #load "FSCharting.Gtk.fsx".

Produces error message:

/notebooks/input.fsx(2,1): error FS0078: Unable to find the file 'FSCharting.Gtk.fsx' in any of
 /IfSharp/bin
 /notebooks
simra commented 7 years ago

Charting seems to be in flux and the documentation is quite out of date. The one example I got to work was @dsyme's azure notebook (you have to manually re-run the cells to produce a chart). This link may work but I'm not sure whether it corresponds to his or mine: https://notebooks.azure.com/n/bclfpmMZuMU/notebooks/fsharp-advanced-guide.ipynb

I can't find FSCharting.* in the repo, I think it has been renamed to FSharp.Charting.Gtk.fsx and FSharp.Charting.fsx for Windows.

Every legacy example I can find fails to run- all of them assume FSharp.Charting is pre-loaded, or reference FSCharting*.fsx.

I got this very strange outcome when I grabbed FSharp.Charting from nuget and then tried to load FSharp.Charting.fsx:

#N "Fsharp.Charting"
#load "FSharp.Charting.fsx"

...
Chart.Line(data)
|> Chart.WithXAxis(true, "", 3.2, -3.2)
|> Chart.WithYAxis(true, "", 1.0, -1.0)
|> Display

​Out[2]:
NuGet package: FSharp.Charting
Out[2]:
Referenced: C:\Users\rsim\Documents\packages\FSharp.Charting.0.90.14\lib\net40\FSharp.Charting.dll

followed by this error:

error FS0082: Could not resolve this reference. Could not locate the assembly "FSharp.Charting.dll". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (Code=MSB3245)

But I am able to get Don's XPlot example to work:

#load "XPlot.Plotly.Paket.fsx"
#load "XPlot.Plotly.fsx"
open XPlot.Plotly
Heatmap(z = [[1; 20; 30]; [20; 1; 60]; [30; 60; 1]])
    |> Chart.Plot
    |> Chart.WithLayout (Layout(title = "Simple Heatmap"))

or

#load "XPlot.Plotly.Paket.fsx"
#load "XPlot.Plotly.fsx"
open XPlot.Plotly
["giraffes", 20; "orangutans", 14; "monkeys", 23]
    |> Chart.Bar
    |> Chart.WithLayout (Layout(title = "Basic Bar Chart"))
    |> Chart.WithHeight 300
    |> Chart.WithWidth 400

Would be great if at a minimum there was a working example in the README.md, and as well as in these locations: https://github.com/fsprojects/IfSharp/blob/master/Feature%20Notebook%20format%204_0.ipynb http://bayardrock.github.io/IfSharp/

cgravill commented 7 years ago

For the original question, it's been renamed to FSharp.Charting.Gtk.fsx and a corresponding FSharp.Charting.Gtk.Paket.fsx. Fair warning I don't know how well the GTK version works. This was contributed by @npmurphy who I think may use some of the client-side charting libraries like XPlot now,

cgravill commented 7 years ago

@simra yes the documentation has definitely lagged behind the changes and needs updating.

The overall intention is to make improve cross-platform support and allow people to upgrade all packages. The previous examples did expect FSharp.Charting to be built-in which caused issues with updating.

If you want to use FSharp Charting you can do so like this:

#load "Fsharp.Charting.paket.fsx"
#load "Fsharp.Charting.fsx"

open FSharp.Charting

Chart.Line [ for x in 0 .. 10 -> x, x*x ]

image

the equivalent on Linux/Mac (or for that matter GTK on Windows) would be:

//This is untested
#load "Fsharp.Charting.GTK.paket.fsx"
#load "Fsharp.Charting.GTK.fsx"

open FSharp.Charting

Chart.Line [ for x in 0 .. 10 -> x, x*x ]
cgravill commented 7 years ago

I have updated the feature notebook to use more up to date samples - a shortened version of what's on Azure Notebooks and updated the links from the readme. I also removed the charting example on there for now.

The documentation on http://bayardrock.github.io/IfSharp/ corresponds to the now archived version of IfSharp at: https://github.com/fsprojects/IfSharp/tree/ipython-archive I have now removed the link to this documentation on the readme. For most users it's just unhelpful. Perhaps we should mark that documentation as explicitly not current.

For the #N then unfortunately there are some issues, see #106. In our work we're pretty much completely switched to using Paket, via #load "Paket.fsx". I've added a pull request in #107 to help people migrate which I'd like feedback on. Alternatively if someone wants to fix #N that would be great. It's not been intentionally affected and I hoped to just leave it in place.

Thanks for pointing these out, hope the above improves it somewhat.

simra commented 7 years ago

Nice! Thanks for info and the quick updates.

cgravill commented 7 years ago

Great, the documentation updates and #107 update to help migrate from #N syntax looks like enough to cover this.