Skip to content

Commit a7e7473

Browse files
committed
Add al histogram2Dcontour params, rename 2d -> 2D
1 parent 9a34c85 commit a7e7473

File tree

7 files changed

+268
-213
lines changed

7 files changed

+268
-213
lines changed

docs/00_1_image-export.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ open Plotly.NET
6565
open Plotly.NET.ImageExport
6666

6767
let exampleChart =
68-
Chart.Histogram2dContour(
68+
Chart.Histogram2DContour(
6969
[1.;2.;2.;4.;5.],
7070
[1.;2.;2.;4.;5.]
7171
)

docs/04_4_2d-histograms.fsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ let x = Array.init n (fun i -> ((step i)**3.) + (0.3 * (normal (rnd) 0. 2.) ))
5757
let y = Array.init n (fun i -> ((step i)**6.) + (0.3 * (normal (rnd) 0. 2.) ))
5858

5959
(**
60-
A Histogram2d chart can be created using the `Chart.Histogram2d` or `Chart.Histogram2dContour` functions.
60+
A Histogram2D chart can be created using the `Chart.Histogram2D` or `Chart.Histogram2DContour` functions.
6161
*)
6262

6363
let histogramContour =
6464
[
65-
Chart.Histogram2dContour (x,y,Line=Line.init(Width=0.))
65+
Chart.Histogram2DContour (x,y,Line=Line.init(Width=0.))
6666
Chart.Point(x,y,Opacity=0.3)
6767
]
6868
|> Chart.combine
@@ -76,14 +76,14 @@ histogramContour
7676
histogramContour |> GenericChart.toChartHTML
7777
(*** include-it-raw ***)
7878

79-
let histogram2d =
80-
Chart.Histogram2d (x,y)
79+
let histogram2D =
80+
Chart.Histogram2D (x,y)
8181

8282
(*** condition: ipynb ***)
8383
#if IPYNB
84-
histogram2d
84+
histogram2D
8585
#endif // IPYNB
8686

8787
(***hide***)
88-
histogram2d |> GenericChart.toChartHTML
88+
histogram2D |> GenericChart.toChartHTML
8989
(*** include-it-raw ***)

src/Plotly.NET/ChartAPI/Chart.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ type Chart =
296296
static member withX_Axis(xAxis:LinearAxis,[<Optional;DefaultParameterValue(null)>] ?Id : StyleParam.SubPlotId) =
297297
Chart.withXAxis(xAxis, ?Id = Id)
298298

299-
// Sets x-Axis of 2d and 3d- Charts
299+
// Sets x-Axis of 2D and 3d- Charts
300300
[<CompiledName("WithXAxis")>]
301301
static member withXAxis(xAxis:LinearAxis,[<Optional;DefaultParameterValue(null)>] ?Id: StyleParam.SubPlotId) =
302302
fun (ch:GenericChart) ->
@@ -358,7 +358,7 @@ type Chart =
358358
?Anchor = Anchor)
359359

360360

361-
// Sets x-Axis of 2d and 3d- Charts
361+
// Sets x-Axis of 2D and 3d- Charts
362362
[<CompiledName("WithXAxisStyle")>]
363363
static member withXAxisStyle(title,
364364
[<Optional;DefaultParameterValue(null)>] ?TitleFont,
@@ -396,7 +396,7 @@ type Chart =
396396
static member withY_Axis(yAxis:LinearAxis,[<Optional;DefaultParameterValue(null)>] ?Id: StyleParam.SubPlotId) =
397397
Chart.withYAxis(yAxis, ?Id = Id)
398398

399-
// Sets y-Axis of 2d and 3d- Charts
399+
// Sets y-Axis of 2D and 3d- Charts
400400
[<CompiledName("WithYAxis")>]
401401
static member withYAxis(yAxis:LinearAxis,[<Optional;DefaultParameterValue(null)>] ?Id: StyleParam.SubPlotId) =
402402
fun (ch:GenericChart) ->
@@ -559,7 +559,7 @@ type Chart =
559559
[<Optional;DefaultParameterValue(null)>] ?BGColor) =
560560
let colorbar = ColorBar.init(Title=title,?Len = Length,?OutlineColor=OutlineColor,?BGColor=BGColor,?BorderColor=BorderColor)
561561
Chart.withColorBar(colorbar)
562-
//// Sets second x-Axis of 2d- Charts
562+
//// Sets second x-Axis of 2D- Charts
563563
//static member withX_Axis2(xAxis2:Axis.LinearAxis) =
564564
// (fun (ch:GenericChart) ->
565565
// let layout =
@@ -569,14 +569,14 @@ type Chart =
569569
// )
570570

571571

572-
// // Sets second x-Axis of 2d- Charts
572+
// // Sets second x-Axis of 2D- Charts
573573
//static member withX_Axis2Style(title,?MinMax,?Showgrid,?Showline) =
574574
// let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None
575575
// let xaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Top)
576576
// Chart.withX_Axis2(xaxis)
577577

578578

579-
//// Sets second y-Axis of 2d- Charts
579+
//// Sets second y-Axis of 2D- Charts
580580
//static member withY_Axis2(yAxis2:Axis.LinearAxis) =
581581
// (fun (ch:GenericChart) ->
582582
// let layout =
@@ -586,7 +586,7 @@ type Chart =
586586
// )
587587

588588

589-
// // Sets second x-Axis of 2d- Charts
589+
// // Sets second x-Axis of 2D- Charts
590590
//static member withY_Axis2Style(title,?MinMax,?Showgrid,?Showline) =
591591
// let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None
592592
// let yaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Right)

src/Plotly.NET/ChartAPI/Chart2D.fs

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ module Chart2D =
15191519

15201520
/// Computes the bi-dimensional histogram of two data samples.
15211521
[<Extension>]
1522-
static member Histogram2d
1522+
static member Histogram2D
15231523
(
15241524
x : seq<#IConvertible>,
15251525
y : seq<#IConvertible>,
@@ -1543,8 +1543,8 @@ module Chart2D =
15431543
[<Optional;DefaultParameterValue(null)>] ?ReverseScale : bool,
15441544
[<Optional;DefaultParameterValue(null)>] ?ZSmooth : StyleParam.SmoothAlg
15451545
) =
1546-
Trace2D.initHistogram2d (
1547-
Trace2DStyle.Histogram2d (
1546+
Trace2D.initHistogram2D (
1547+
Trace2DStyle.Histogram2D (
15481548
X = x ,
15491549
?XGap = XGap ,
15501550
Y = y ,
@@ -1826,43 +1826,60 @@ module Chart2D =
18261826

18271827
/// Computes the bi-dimensional histogram of two data samples and auto-determines the bin size.
18281828
[<Extension>]
1829-
static member Histogram2dContour
1829+
static member Histogram2DContour
18301830
(
1831-
x,y,
1832-
[<Optional;DefaultParameterValue(null)>] ?Z,
1833-
[<Optional;DefaultParameterValue(null)>] ?Name,
1834-
[<Optional;DefaultParameterValue(null)>] ?Colorscale,
1835-
[<Optional;DefaultParameterValue(null)>] ?Showscale,
1836-
[<Optional;DefaultParameterValue(null)>] ?Line,
1837-
[<Optional;DefaultParameterValue(null)>] ?zSmooth,
1838-
[<Optional;DefaultParameterValue(null)>] ?ColorBar,
1839-
[<Optional;DefaultParameterValue(null)>] ?zAuto,
1840-
[<Optional;DefaultParameterValue(null)>] ?zMin,
1841-
[<Optional;DefaultParameterValue(null)>] ?zMax,
1842-
[<Optional;DefaultParameterValue(null)>] ?nBinsx,
1843-
[<Optional;DefaultParameterValue(null)>] ?nBinsy,
1844-
[<Optional;DefaultParameterValue(null)>] ?xBins,
1845-
[<Optional;DefaultParameterValue(null)>] ?yBins,
1846-
[<Optional;DefaultParameterValue(null)>] ?HistNorm,
1847-
[<Optional;DefaultParameterValue(null)>] ?HistFunc
1848-
) =
1849-
Trace2D.initHistogram2dContour (
1850-
Trace2DStyle.Histogram2dContour (X=x, Y=y,? Z=Z,?Line=Line,
1851-
?Colorscale=Colorscale,
1852-
?Showscale=Showscale,
1853-
?zSmooth=zSmooth,
1854-
?ColorBar=ColorBar,
1855-
?zAuto=zAuto,
1856-
?zMin=zMin,
1857-
?zMax=zMax,
1858-
?nBinsx=nBinsx,
1859-
?nBinsy=nBinsy,
1860-
?xBins=xBins,
1861-
?yBins=yBins,
1862-
?HistNorm=HistNorm,
1863-
?HistFunc=HistFunc
1831+
x : seq<#IConvertible>,
1832+
y : seq<#IConvertible>,
1833+
[<Optional;DefaultParameterValue(null)>] ?Name : string,
1834+
[<Optional;DefaultParameterValue(null)>] ?ShowLegend : bool,
1835+
[<Optional;DefaultParameterValue(null)>] ?Opacity : float,
1836+
[<Optional;DefaultParameterValue(null)>] ?Z : seq<#seq<#IConvertible>>,
1837+
[<Optional;DefaultParameterValue(null)>] ?HistFunc : StyleParam.HistFunc,
1838+
[<Optional;DefaultParameterValue(null)>] ?HistNorm : StyleParam.HistNorm,
1839+
[<Optional;DefaultParameterValue(null)>] ?NBinsX : int,
1840+
[<Optional;DefaultParameterValue(null)>] ?NBinsY : int,
1841+
[<Optional;DefaultParameterValue(null)>] ?BinGroup : string,
1842+
[<Optional;DefaultParameterValue(null)>] ?XBinGroup : string,
1843+
[<Optional;DefaultParameterValue(null)>] ?XBins : Bins,
1844+
[<Optional;DefaultParameterValue(null)>] ?YBinGroup : string,
1845+
[<Optional;DefaultParameterValue(null)>] ?YBins : Bins,
1846+
[<Optional;DefaultParameterValue(null)>] ?Marker : Marker,
1847+
[<Optional;DefaultParameterValue(null)>] ?LineDash : StyleParam.DrawingStyle,
1848+
[<Optional;DefaultParameterValue(null)>] ?LineColor : Color,
1849+
[<Optional;DefaultParameterValue(null)>] ?Line : Line,
1850+
[<Optional;DefaultParameterValue(null)>] ?ColorBar : ColorBar,
1851+
[<Optional;DefaultParameterValue(null)>] ?ColorScale : StyleParam.Colorscale,
1852+
[<Optional;DefaultParameterValue(null)>] ?ShowScale : bool,
1853+
[<Optional;DefaultParameterValue(null)>] ?ReverseScale : bool,
1854+
[<Optional;DefaultParameterValue(null)>] ?Contours : Contours,
1855+
[<Optional;DefaultParameterValue(null)>] ?NContours : int
1856+
) =
1857+
Trace2D.initHistogram2DContour (
1858+
Trace2DStyle.Histogram2DContour (
1859+
X = x,
1860+
Y = y,
1861+
?Z = Z ,
1862+
?HistFunc = HistFunc ,
1863+
?HistNorm = HistNorm ,
1864+
?NBinsX = NBinsX ,
1865+
?NBinsY = NBinsY ,
1866+
?BinGroup = BinGroup ,
1867+
?XBinGroup = XBinGroup ,
1868+
?XBins = XBins ,
1869+
?YBinGroup = YBinGroup ,
1870+
?YBins = YBins ,
1871+
?Marker = Marker ,
1872+
?Line = Line ,
1873+
?ColorBar = ColorBar ,
1874+
?ColorScale = ColorScale ,
1875+
?ShowScale = ShowScale ,
1876+
?ReverseScale = ReverseScale,
1877+
?Contours = Contours ,
1878+
?NContours = NContours
18641879
)
18651880
)
1881+
|> TraceStyle.TraceInfo(?Name=Name, ?ShowLegend=ShowLegend, ?Opacity=Opacity)
1882+
|> TraceStyle.Line(?Color=LineColor, ?Dash=LineDash)
18661883
|> GenericChart.ofTraceObject
18671884

18681885
/// Shows a graphical representation of a 3-dimensional surface by plotting constant z slices, called contours, on a 2-dimensional format.

src/Plotly.NET/Playground.fsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,24 @@ open FSharpAux
161161
open System
162162
open System.IO
163163

164+
let y=[2.37; 2.16; 4.82; 1.73; 1.04; 0.23; 1.32; 2.91; 0.11; 4.51; 0.51; 3.75; 1.35; 2.98; 4.50; 0.18; 4.66; 1.30; 2.06; 1.19]
164165

166+
[
167+
Chart.BoxPlot(y=y,BoxPoints=StyleParam.BoxPoints.All,Jitter=0.5,Notched=true,MarkerColor = Color.fromString "red",BoxMean=StyleParam.BoxMean.True,Name="Only Mean");
168+
Chart.BoxPlot(y=y,BoxPoints=StyleParam.BoxPoints.All,Jitter=0.5,Notched=true,MarkerColor = Color.fromString "blue",BoxMean=StyleParam.BoxMean.SD,Name="Mean & SD")
169+
]
170+
|> Chart.combine
171+
|> Chart.show
172+
173+
Chart.Histogram2DContour(
174+
[for _ in 0 .. 10000 do yield System.Random().NextDouble()],
175+
[for _ in 0 .. 10000 do yield System.Random().NextDouble()],
176+
LineDash = StyleParam.DrawingStyle.DashDot,
177+
NContours= 20,
178+
LineColor= Color.fromKeyword White,
179+
ColorScale = StyleParam.Colorscale.Viridis
180+
)
181+
|> Chart.show
165182

166183
[
167184
Chart.Histogram(
@@ -170,15 +187,17 @@ open System.IO
170187
HistFunc = StyleParam.HistFunc.Avg,
171188
HistNorm = StyleParam.HistNorm.ProbabilityDensity,
172189
BinGroup = "myHist",
173-
Opacity = 0.6
190+
Opacity = 0.6,
191+
Cumulative = Cumulative.init(Enabled=true)
174192
)
175193
Chart.Histogram(
176194
[for i in 0 .. 1000 do yield System.Random().NextDouble() * 10.],
177195
StyleParam.Orientation.Vertical,
178196
HistFunc = StyleParam.HistFunc.Avg,
179197
HistNorm = StyleParam.HistNorm.ProbabilityDensity,
180198
BinGroup = "myHist",
181-
Opacity = 0.6
199+
Opacity = 0.6,
200+
Cumulative = Cumulative.init(Enabled=true,Direction = StyleParam.CumulativeDirection.Decreasing)
182201
)
183202
]
184203
|> Chart.combine
@@ -664,8 +683,8 @@ Chart.Invisible()
664683

665684

666685
[
667-
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All);
668-
Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All);
686+
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
687+
Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
669688
]
670689
|> Chart.combine
671690

@@ -705,8 +724,8 @@ let heatmap2=
705724
Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
706725
[
707726
let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]
708-
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All);
709-
Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All);
727+
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
728+
Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
710729
]
711730
|> Chart.combine
712731
]

0 commit comments

Comments
 (0)