Plot CSV Data in F#

How to create charts from csv files with Plotly and F#


Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.

Note: We are retiring documentation for R, MATLAB, Julia, and F# in November 2025. Learn more about this change here.

In [1]:
#r "nuget: Plotly.NET, 2.0.0-preview.8" #r "nuget: Plotly.NET.Interactive, 2.0.0-preview.8" #r "nuget: FSharp.Data" #r "nuget:Deedle" 
Installed Packages
  • Deedle, 2.4.3
  • FSharp.Data, 4.2.4
  • Plotly.NET, 2.0.0-preview.8
  • Plotly.NET.Interactive, 2.0.0-preview.8

Loading extensions from Plotly.NET.Interactive.dll

Added Kernel Extension including formatters for Plotly.NET charts.

Plot from CSV with Plotly

In [2]:
open FSharp.Data open Deedle open Plotly.NET open Plotly.NET.LayoutObjects let dataset = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/2014_apple_stock.csv" |> fun csv -> Frame.ReadCsvString(csv,true,separators=",") let getColumn column= dataset |> Frame.getCol column |> Series.values let xy = Seq.zip (getColumn "AAPL_x" :> seq<DateTime>) (getColumn "AAPL_y" :> seq<float>) Chart.Line(xy,Name="Share Prices (in USD)") |>Chart.withLayout(Layout.init(Title.init("Apple Share Prices over time (2014)"),PlotBGColor=Color.fromString "#e5ecf6",ShowLegend=true,Width=1100)) |>Chart.withXAxis(LinearAxis.init(Title=Title.init("AAPL_x"),ZeroLineColor=Color.fromString"#ffff",ZeroLineWidth=2.,GridColor=Color.fromString"#ffff" )) |>Chart.withYAxis(LinearAxis.init(Title=Title.init("AAPL_y"),ZeroLineColor=Color.fromString"#ffff",ZeroLineWidth=2.,GridColor=Color.fromString"#ffff" )) 
Out[2]: