PointDensity

BinderScriptNotebook

Summary: This example shows how to create PointDensity plots in F#.

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

let rnd = new System.Random()
let x = [for i in 0 .. 100 -> rnd.NextDouble()]
let y = [for i in 0 .. 100 -> rnd.NextDouble()]

Chart.PointDensity is a combination of a scatter plot and a histogram2dcontour.

It helps assessing the 2 dimensional distribution of a scatter plot by adding density contours based on the same data.

open Plotly.NET

let pointDensityChart = 
    Chart.PointDensity(x,y)

More styled example

This example shows the usage of some of the styling possibility using Chart.PointDensity.

let pointDensityChartStyled = 
    Chart.PointDensity(
        x,
        y,
        PointMarkerColor = Color.fromKeyword Purple,
        PointMarkerSymbol = StyleParam.MarkerSymbol.X,
        PointMarkerSize = 4,
        ColorScale = StyleParam.Colorscale.Viridis,
        ColorBar = ColorBar.init(Title = Title.init("Density")),
        ShowContourLabels = true
    )
val rnd: System.Random
namespace System
Multiple items
type Random = new: unit -> unit + 1 overload member Next: unit -> int + 2 overloads member NextBytes: buffer: byte[] -> unit + 1 overload member NextDouble: unit -> float member NextInt64: unit -> int64 + 2 overloads member NextSingle: unit -> float32 static member Shared: Random
<summary>Represents a pseudo-random number generator, which is an algorithm that produces a sequence of numbers that meet certain statistical requirements for randomness.</summary>

--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val x: float list
val i: int
System.Random.NextDouble() : float
val y: float list
namespace Plotly
namespace Plotly.NET
val pointDensityChart: GenericChart.GenericChart
type Chart = static member AnnotatedHeatmap: zData: seq<#seq<'a1>> * annotationText: seq<#seq<string>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?X: seq<#IConvertible> * ?XGap: int * ?Y: seq<#IConvertible> * ?YGap: int * ?Text: 'a5 * ?MultiText: seq<'a5> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a5 :> IConvertible) + 1 overload static member Area: x: seq<#IConvertible> * y: seq<#IConvertible> * ?ShowMarkers: bool * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: seq<MarkerSymbol> * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?FillColor: Color * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) + 1 overload static member Bar: values: seq<#IConvertible> * ?Keys: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerPatternShape: PatternShape * ?MultiMarkerPatternShape: seq<PatternShape> * ?MarkerPattern: Pattern * ?Marker: Marker * ?Base: #IConvertible * ?Width: 'a4 * ?MultiWidth: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible and 'a4 :> IConvertible) + 1 overload static member BoxPlot: ?X: seq<#IConvertible> * ?Y: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Text: 'a2 * ?MultiText: seq<'a2> * ?FillColor: Color * ?MarkerColor: Color * ?Marker: Marker * ?Opacity: float * ?WhiskerWidth: float * ?BoxPoints: BoxPoints * ?BoxMean: BoxMean * ?Jitter: float * ?PointPos: float * ?Orientation: Orientation * ?OutlineColor: Color * ?OutlineWidth: float * ?Outline: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?Notched: bool * ?NotchWidth: float * ?QuartileMethod: QuartileMethod * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) + 2 overloads static member Bubble: x: seq<#IConvertible> * y: seq<#IConvertible> * sizes: seq<int> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: seq<MarkerSymbol> * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) + 1 overload static member Candlestick: ``open`` : seq<#IConvertible> * high: seq<#IConvertible> * low: seq<#IConvertible> * close: seq<#IConvertible> * x: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Text: 'a5 * ?MultiText: seq<'a5> * ?Line: Line * ?IncreasingColor: Color * ?Increasing: FinanceMarker * ?DecreasingColor: Color * ?Decreasing: FinanceMarker * ?WhiskerWidth: float * ?UseDefaults: bool -> GenericChart (requires 'a5 :> IConvertible) + 1 overload static member Column: values: seq<#IConvertible> * ?Keys: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: seq<float> * ?Text: 'a2 * ?MultiText: seq<'a2> * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerPatternShape: PatternShape * ?MultiMarkerPatternShape: seq<PatternShape> * ?MarkerPattern: Pattern * ?Marker: Marker * ?Base: #IConvertible * ?Width: 'a4 * ?MultiWidth: seq<'a4> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible and 'a4 :> IConvertible) + 1 overload static member Contour: zData: seq<#seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?X: seq<#IConvertible> * ?Y: seq<#IConvertible> * ?Text: 'a4 * ?MultiText: seq<'a4> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?Transpose: bool * ?ContourLineColor: Color * ?ContourLineDash: DrawingStyle * ?ContourLineSmoothing: float * ?ContourLine: Line * ?ContoursColoring: ContourColoring * ?ContoursOperation: ConstraintOperation * ?ContoursType: ContourType * ?ShowContourLabels: bool * ?ContourLabelFont: Font * ?Contours: Contours * ?FillColor: Color * ?NContours: int * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a4 :> IConvertible) static member Funnel: x: seq<#IConvertible> * y: seq<#IConvertible> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Width: float * ?Offset: float * ?Text: 'a2 * ?MultiText: seq<'a2> * ?TextPosition: TextPosition * ?MultiTextPosition: seq<TextPosition> * ?Orientation: Orientation * ?AlignmentGroup: string * ?OffsetGroup: string * ?MarkerColor: Color * ?MarkerOutline: Line * ?Marker: Marker * ?TextInfo: TextInfo * ?ConnectorLineColor: Color * ?ConnectorLineStyle: DrawingStyle * ?ConnectorFillColor: Color * ?ConnectorLine: Line * ?Connector: FunnelConnector * ?InsideTextFont: Font * ?OutsideTextFont: Font * ?UseDefaults: bool -> GenericChart (requires 'a2 :> IConvertible) static member Heatmap: zData: seq<#seq<'a1>> * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?X: seq<#IConvertible> * ?XGap: int * ?Y: seq<#IConvertible> * ?YGap: int * ?Text: 'a4 * ?MultiText: seq<'a4> * ?ColorBar: ColorBar * ?ColorScale: Colorscale * ?ShowScale: bool * ?ReverseScale: bool * ?ZSmooth: SmoothAlg * ?Transpose: bool * ?UseWebGL: bool * ?ReverseYAxis: bool * ?UseDefaults: bool -> GenericChart (requires 'a1 :> IConvertible and 'a4 :> IConvertible) + 1 overload ...
static member Chart.PointDensity: x: seq<#System.IConvertible> * y: seq<#System.IConvertible> * ?PointOpacity: float * ?PointMarkerColor: Color * ?PointMarkerSymbol: StyleParam.MarkerSymbol * ?PointMarkerSize: int * ?ContourLineColor: Color * ?ContourLineSmoothing: float * ?ContourLineWidth: float * ?ShowContourLines: bool * ?ShowContourLabels: bool * ?ContourColoring: StyleParam.ContourColoring * ?NContours: int * ?HistNorm: StyleParam.HistNorm * ?ContourOpacity: float * ?ColorBar: ColorBar * ?ColorScale: StyleParam.Colorscale * ?ShowScale: bool * ?UseDefaults: bool -> GenericChart.GenericChart
module GenericChart from Plotly.NET
<summary> Module to represent a GenericChart </summary>
val toChartHTML: gChart: GenericChart.GenericChart -> string
<summary> Converts a GenericChart to it HTML representation. The div layer has a default size of 600 if not specified otherwise. </summary>
val pointDensityChartStyled: GenericChart.GenericChart
type Color = override Equals: other: obj -> bool override GetHashCode: unit -> int static member fromARGB: a: int -> r: int -> g: int -> b: int -> Color static member fromColorScaleValues: c: seq<#IConvertible> -> Color static member fromColors: c: seq<Color> -> Color static member fromHex: s: string -> Color static member fromKeyword: c: ColorKeyword -> Color static member fromRGB: r: int -> g: int -> b: int -> Color static member fromString: c: string -> Color member Value: obj
<summary> Plotly color can be a single color, a sequence of colors, or a sequence of numeric values referencing the color of the colorscale obj </summary>
static member Color.fromKeyword: c: ColorKeyword -> Color
union case ColorKeyword.Purple: ColorKeyword
module StyleParam from Plotly.NET
type MarkerSymbol = | Modified of MarkerSymbol * SymbolStyle | Circle | Square | Diamond | Cross | X | TriangleUp | TriangleDown | TriangleLeft | TriangleRight ... member Convert: unit -> obj override ToString: unit -> string static member convert: (MarkerSymbol -> obj) static member toInteger: (MarkerSymbol -> int)
union case StyleParam.MarkerSymbol.X: StyleParam.MarkerSymbol
type Colorscale = | Custom of seq<float * Color> | RdBu | Earth | Blackbody | YIOrRd | YIGnBu | Bluered | Portland | Electric | Jet ... member Convert: unit -> obj static member convert: (Colorscale -> obj)
<summary> The colorscale must be a collection containing a mapping of a normalized value (between 0.0 and 1.0) to it's color. At minimum, a mapping for the lowest (0.0) and highest (1.0) values are required. </summary>
union case StyleParam.Colorscale.Viridis: StyleParam.Colorscale
Multiple items
type ColorBar = inherit DynamicObj new: unit -> ColorBar static member init: ?BGColor: Color * ?BorderColor: Color * ?BorderWidth: float * ?DTick: IConvertible * ?ExponentFormat: ExponentFormat * ?Len: float * ?LenMode: UnitMode * ?MinExponent: float * ?NTicks: int * ?OutlineColor: Color * ?OutlineWidth: float * ?SeparateThousands: bool * ?ShowExponent: ShowExponent * ?ShowTickLabels: bool * ?ShowTickPrefix: ShowTickOption * ?ShowTickSuffix: ShowTickOption * ?Thickness: float * ?ThicknessMode: UnitMode * ?Tick0: IConvertible * ?TickAngle: int * ?TickColor: Color * ?TickFont: Font * ?TickFormat: string * ?TickFormatStops: seq<TickFormatStop> * ?TickLabelOverflow: TickLabelOverflow * ?TickLabelPosition: TickLabelPosition * ?TickLen: float * ?TickMode: TickMode * ?TickPrefix: string * ?Ticks: TickOptions * ?TickSuffix: string * ?TickText: seq<#IConvertible> * ?TickVals: seq<#IConvertible> * ?TickWidth: float * ?Title: Title * ?X: float * ?XAnchor: HorizontalAlign * ?XPad: float * ?Y: float * ?YAnchor: VerticalAlign * ?YPad: float -> ColorBar static member style: ?BGColor: Color * ?BorderColor: Color * ?BorderWidth: float * ?DTick: IConvertible * ?ExponentFormat: ExponentFormat * ?Len: float * ?LenMode: UnitMode * ?MinExponent: float * ?NTicks: int * ?OutlineColor: Color * ?OutlineWidth: float * ?SeparateThousands: bool * ?ShowExponent: ShowExponent * ?ShowTickLabels: bool * ?ShowTickPrefix: ShowTickOption * ?ShowTickSuffix: ShowTickOption * ?Thickness: float * ?ThicknessMode: UnitMode * ?Tick0: IConvertible * ?TickAngle: int * ?TickColor: Color * ?TickFont: Font * ?TickFormat: string * ?TickFormatStops: seq<TickFormatStop> * ?TickLabelOverflow: TickLabelOverflow * ?TickLabelPosition: TickLabelPosition * ?TickLen: float * ?TickMode: TickMode * ?TickPrefix: string * ?Ticks: TickOptions * ?TickSuffix: string * ?TickText: seq<#IConvertible> * ?TickVals: seq<#IConvertible> * ?TickWidth: float * ?Title: Title * ?X: float * ?XAnchor: HorizontalAlign * ?XPad: float * ?Y: float * ?YAnchor: VerticalAlign * ?YPad: float -> (ColorBar -> ColorBar)
<summary> The ColorBar object to be used with ColorAxes. </summary>

--------------------
new: unit -> ColorBar
static member ColorBar.init: ?BGColor: Color * ?BorderColor: Color * ?BorderWidth: float * ?DTick: System.IConvertible * ?ExponentFormat: StyleParam.ExponentFormat * ?Len: float * ?LenMode: StyleParam.UnitMode * ?MinExponent: float * ?NTicks: int * ?OutlineColor: Color * ?OutlineWidth: float * ?SeparateThousands: bool * ?ShowExponent: StyleParam.ShowExponent * ?ShowTickLabels: bool * ?ShowTickPrefix: StyleParam.ShowTickOption * ?ShowTickSuffix: StyleParam.ShowTickOption * ?Thickness: float * ?ThicknessMode: StyleParam.UnitMode * ?Tick0: System.IConvertible * ?TickAngle: int * ?TickColor: Color * ?TickFont: Font * ?TickFormat: string * ?TickFormatStops: seq<TickFormatStop> * ?TickLabelOverflow: StyleParam.TickLabelOverflow * ?TickLabelPosition: StyleParam.TickLabelPosition * ?TickLen: float * ?TickMode: StyleParam.TickMode * ?TickPrefix: string * ?Ticks: StyleParam.TickOptions * ?TickSuffix: string * ?TickText: seq<#System.IConvertible> * ?TickVals: seq<#System.IConvertible> * ?TickWidth: float * ?Title: Title * ?X: float * ?XAnchor: StyleParam.HorizontalAlign * ?XPad: float * ?Y: float * ?YAnchor: StyleParam.VerticalAlign * ?YPad: float -> ColorBar
Multiple items
type Title = inherit DynamicObj new: unit -> Title static member init: ?Text: string * ?Font: Font * ?Standoff: int * ?Side: Side * ?X: float * ?Y: float -> Title static member style: ?Text: string * ?Font: Font * ?Standoff: int * ?Side: Side * ?X: float * ?Y: float -> (Title -> Title)

--------------------
new: unit -> Title
static member Title.init: ?Text: string * ?Font: Font * ?Standoff: int * ?Side: StyleParam.Side * ?X: float * ?Y: float -> Title