2 people like it.
Like the snippet!
Plotly - Vector Field
Plot the vector field v = ( y, -x ) using FSharp.Plotly
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
|
#r "FSharp.Plotly.dll"
open FSharp.Plotly
let vectors = [|
for x in -2.0 .. 0.25 .. 2.0 do
for y in -2.0 .. 0.25 .. 2.0 do
let s = 0.1
let vX, vY = y, -x
let mag = sqrt( vX**2.0 + vY**2.0 )
let vX, vY = s * vX / mag, s * vY / mag
yield (x, x+vX , y, y+vY) |]
let vectorsShapes = vectors |> Array.map (fun (x0, x1 , y0, y1) -> Shape.init( StyleParam.ShapeType.Line, x0, x1 , y0, y1 ))
let vectorsTips = vectors |> Array.map (fun (x0, x1 , y0, y1) -> x1, y1 )
vectorsTips
|> Chart.Point
|> Chart.withShapes vectorsShapes
|> Chart.withSize (1000.0, 1000.0)
|> Chart.Show
|
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Plotly
val vectors : (float * float * float * float) []
val x : float
val y : float
val s : float
val vX : float
val vY : float
val mag : float
val sqrt : value:'T -> 'U (requires member Sqrt)
val vectorsShapes : Shape []
module Array
from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
val x0 : float
val x1 : float
val y0 : float
val y1 : float
Multiple items
type Shape =
inherit DynamicObj
new : unit -> Shape
static member init : ?ShapeType:ShapeType * ?X0:'a * ?X1:'b * ?Y0:'c * ?Y1:'d * ?Path:'e * ?Opacity:'f * ?Line:Line * ?Fillcolor:'g * ?Layer:Layer * ?Xref:'h * ?Yref:'i -> Shape
static member style : ?ShapeType:ShapeType * ?X0:'a0 * ?X1:'a1 * ?Y0:'a2 * ?Y1:'a3 * ?Path:'a4 * ?Opacity:'a5 * ?Line:Line * ?Fillcolor:'a6 * ?Layer:Layer * ?Xref:'a7 * ?Yref:'a8 -> (Shape -> Shape)
--------------------
new : unit -> Shape
static member Shape.init : ?ShapeType:StyleParam.ShapeType * ?X0:'a * ?X1:'b * ?Y0:'c * ?Y1:'d * ?Path:'e * ?Opacity:'f * ?Line:Line * ?Fillcolor:'g * ?Layer:StyleParam.Layer * ?Xref:'h * ?Yref:'i -> Shape
module StyleParam
from FSharp.Plotly
type ShapeType =
| Circle
| Rectangle
| SvgPath
| Line
static member convert : (ShapeType -> obj)
static member toString : (ShapeType -> string)
union case StyleParam.ShapeType.Line: StyleParam.ShapeType
val vectorsTips : (float * float) []
type Chart =
static member Area : xy:seq<#IConvertible * #IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:'a4 -> GenericChart
static member Area : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:'a4 -> GenericChart
static member Bar : keysvalues:seq<#IConvertible * #IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart
static member Bar : keys:seq<#IConvertible> * values:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart
static member BoxPlot : xy:seq<'a0 * 'a1> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Fillcolor:'a3 * ?Opacity:float * ?Whiskerwidth:'a4 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a5 * ?Pointpos:'a6 * ?Orientation:Orientation -> GenericChart
static member BoxPlot : ?x:'a0 * ?y:'a1 * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Fillcolor:'a3 * ?Opacity:float * ?Whiskerwidth:'a4 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a5 * ?Pointpos:'a6 * ?Orientation:Orientation -> GenericChart
static member Bubble : xysizes:seq<#IConvertible * #IConvertible * #IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:'a3 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font -> GenericChart
static member Bubble : x:seq<#IConvertible> * y:seq<#IConvertible> * sizes:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:'a3 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font -> GenericChart
static member ChoroplethMap : locations:seq<string> * z:seq<#IConvertible> * ?Text:seq<#IConvertible> * ?Locationmode:LocationFormat * ?Autocolorscale:bool * ?Colorscale:Colorscale * ?Colorbar:'a2 * ?Marker:Marker * ?Zmin:'a3 * ?Zmax:'a4 -> GenericChart
static member Column : keysvalues:seq<#IConvertible * #IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart
...
static member Chart.Point : xy:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:StyleParam.Symbol * ?Color:'c * ?Opacity:float * ?Labels:seq<#System.IConvertible> * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font -> GenericChart.GenericChart
static member Chart.Point : x:seq<#System.IConvertible> * y:seq<#System.IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:StyleParam.Symbol * ?Color:'a2 * ?Opacity:float * ?Labels:seq<#System.IConvertible> * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font -> GenericChart.GenericChart
static member Chart.withShapes : shapes:seq<Shape> -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withSize : width:float * heigth:float -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.Show : ch:GenericChart.GenericChart -> unit
More information