In [ ]:
#r "nuget: Plotly.NET, 2.0.0"
#r "nuget: Plotly.NET.Interactive, 2.0.0"

Annotations

BinderScriptNotebook

Summary: This example shows how to create Shapes and add them to the Charts in F#.

let's first create some data for the purpose of creating example charts:

In [3]:
open Plotly.NET 
  
let x  = [1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ]
let y' = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]

use the Annotation.init function to generate a shape, and either the Chart.withAnnotation or the Chart.withAnnotations function to add multiple annotations at once.

In [4]:
open Plotly.NET.LayoutObjects

let a1 = Annotation.init (X=2.,Y=4.,Text = "Hi there!")
let a2 = Annotation.init (X=5.,Y=7.,Text="I am another annotation!",BGColor= Color.fromString "white",BorderColor= Color.fromString  "black")

let annotations =
    Chart.Line(x,y',Name="line")    
    |> Chart.withAnnotations([a1;a2])
In [ ]:
annotations
Out[ ]: