From efdb11514c77d48ecbb115e6af63b794af8e7ea7 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Tue, 12 Oct 2021 17:56:33 +0200 Subject: [PATCH 01/11] Add all params to BoxPlot TraceStyle --- .../CommonAbstractions/StyleParams.fs | 10 +- src/Plotly.NET/Traces/Trace2D.fs | 172 +++++++++++++----- 2 files changed, 131 insertions(+), 51 deletions(-) diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index c216e0a67..d7f98045b 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -224,7 +224,7 @@ module StyleParam = //-------------------------- [] - type Boxpoints = + type BoxPoints = | Outliers | All | Suspectedoutliers @@ -236,9 +236,9 @@ module StyleParam = | Suspectedoutliers -> "suspectedoutliers" | False -> "false" - static member convert = Boxpoints.toString >> box - override this.ToString() = this |> Boxpoints.toString - member this.Convert() = this |> Boxpoints.convert + static member convert = BoxPoints.toString >> box + override this.ToString() = this |> BoxPoints.toString + member this.Convert() = this |> BoxPoints.convert @@ -1235,7 +1235,7 @@ module StyleParam = // #J# [] - type Jitterpoints = Boxpoints + type JitterPoints = BoxPoints //-------------------------- // #K# diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index 194fbe6d7..be124b78e 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -595,55 +595,135 @@ type Trace2DStyle() = // Applies the styles of box plot plot to TraceObjects static member BoxPlot ( - [] ?Y, - [] ?X, - [] ?X0, - [] ?Y0, - [] ?Whiskerwidth, - [] ?Boxpoints, - [] ?Boxmean, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Fillcolor : Color, - [] ?Marker:Marker, - [] ?Line:Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Notched:bool, - [] ?NotchWidth:float, - [] ?QuartileMethod:StyleParam.QuartileMethod, - [] ?xAxis, - [] ?yAxis, - [] ?Ysrc, - [] ?Xsrc + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?X0 : #IConvertible, + [] ?DX : #IConvertible, + [] ?Y : seq<#IConvertible>, + [] ?Y0 : #IConvertible, + [] ?DY : #IConvertible, + [] ?Width : float, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HoverText : string, + [] ?MultiHoverText : seq, + [] ?HoverInfo : StyleParam.HoverInfo, + [] ?HoverTemplate : string, + [] ?MultiHoverTemplate: seq, + [] ?XHoverFormat : string, + [] ?YHoverFormat : string, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Orientation : StyleParam.Orientation, + [] ?AlignmentGroup : string, + [] ?OffsetGroup : string, + [] ?XPeriod : #IConvertible, + [] ?XPeriodAlignment : StyleParam.PeriodAlignment, + [] ?XPeriod0 : #IConvertible, + [] ?YPeriod : #IConvertible, + [] ?YPeriodAlignment : StyleParam.PeriodAlignment, + [] ?YPeriod0 : #IConvertible, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?BoxMean : StyleParam.BoxMean, + [] ?BoxPoints : StyleParam.BoxPoints, + [] ?Notched : bool, + [] ?NotchWidth : float, + [] ?Whiskerwidth : float, + [] ?Q1 : seq, + [] ?Median : seq, + [] ?Q3 : seq, + [] ?LowerFence : seq, + [] ?UpperFence : seq, + [] ?NotchSpan : seq, + [] ?Mean : seq, + [] ?SD : seq, + [] ?QuartileMethod : StyleParam.QuartileMethod, + [] ?SelectedPoints : seq<#IConvertible>, + [] ?Selected : Selection, + [] ?Unselected : Selection, + [] ?FillColor : Color, + [] ?HoverLabel : Hoverlabel, + [] ?HoverOn : StyleParam.HoverOn, + [] ?PointPos : float, + [] ?Jitter : float, + [] ?XCalendar : StyleParam.Calendar, + [] ?YCalendar : StyleParam.Calendar, + [] ?UIRevision : string ) = (fun (boxPlot:('T :> Trace)) -> - Y |> DynObj.setValueOpt boxPlot "y" - X |> DynObj.setValueOpt boxPlot "x" - X0 |> DynObj.setValueOpt boxPlot "x0" - Y0 |> DynObj.setValueOpt boxPlot "y0" - Whiskerwidth |> DynObj.setValueOpt boxPlot "whiskerwidth" - Boxpoints |> DynObj.setValueOptBy boxPlot "boxpoints" StyleParam.Boxpoints.convert - Boxmean |> DynObj.setValueOptBy boxPlot "boxmean" StyleParam.BoxMean.convert - Jitter |> DynObj.setValueOpt boxPlot "jitter" - Pointpos |> DynObj.setValueOpt boxPlot "pointpos" - Orientation |> DynObj.setValueOptBy boxPlot "orientation" StyleParam.Orientation.convert - Fillcolor |> DynObj.setValueOpt boxPlot "fillcolor" - Marker |> DynObj.setValueOpt boxPlot "marker" - Line |> DynObj.setValueOpt boxPlot "line" - Alignmentgroup |> DynObj.setValueOpt boxPlot "alignmentgroup" - Offsetgroup |> DynObj.setValueOpt boxPlot "offsetgroup" - Notched |> DynObj.setValueOpt boxPlot "notched" - NotchWidth |> DynObj.setValueOpt boxPlot "notchwidth" - QuartileMethod |> DynObj.setValueOptBy boxPlot "quartilemethod" StyleParam.QuartileMethod.convert - - xAxis |> DynObj.setValueOpt boxPlot "xaxis" - yAxis |> DynObj.setValueOpt boxPlot "yaxis" - Ysrc |> DynObj.setValueOpt boxPlot "ysrc" - Xsrc |> DynObj.setValueOpt boxPlot "xsrc" + Name |> DynObj.setValueOpt boxPlot "name" + Visible |> DynObj.setValueOptBy boxPlot "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt boxPlot "showlegend" + LegendRank |> DynObj.setValueOpt boxPlot "legendrank" + LegendGroup |> DynObj.setValueOpt boxPlot "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt boxPlot "legendgrouptitle" + Opacity |> DynObj.setValueOpt boxPlot "opacity" + Ids |> DynObj.setValueOpt boxPlot "ids" + X |> DynObj.setValueOpt boxPlot "x" + X0 |> DynObj.setValueOpt boxPlot "x0" + DX |> DynObj.setValueOpt boxPlot "dx" + Y |> DynObj.setValueOpt boxPlot "y" + Y0 |> DynObj.setValueOpt boxPlot "y0" + DY |> DynObj.setValueOpt boxPlot "dy" + Width |> DynObj.setValueOpt boxPlot "width" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt boxPlot "text" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt boxPlot "hovertext" + HoverInfo |> DynObj.setValueOptBy boxPlot "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt boxPlot "hovertemplate" + XHoverFormat |> DynObj.setValueOpt boxPlot "xhoverformat" + YHoverFormat |> DynObj.setValueOpt boxPlot "yhoverformat" + Meta |> DynObj.setValueOpt boxPlot "meta" + CustomData |> DynObj.setValueOpt boxPlot "customdata" + XAxis |> DynObj.setValueOptBy boxPlot "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy boxPlot "yaxis" StyleParam.LinearAxisId.convert + Orientation |> DynObj.setValueOptBy boxPlot "orientation" StyleParam.Orientation.convert + AlignmentGroup |> DynObj.setValueOpt boxPlot "alignmentgroup" + OffsetGroup |> DynObj.setValueOpt boxPlot "offsetgroup" + XPeriod |> DynObj.setValueOpt boxPlot "xperiod" + XPeriodAlignment |> DynObj.setValueOptBy boxPlot "xperiodalignment" StyleParam.PeriodAlignment.convert + XPeriod0 |> DynObj.setValueOpt boxPlot "xperiod0" + YPeriod |> DynObj.setValueOpt boxPlot "yperiod" + YPeriodAlignment |> DynObj.setValueOptBy boxPlot "yperiodalignment" StyleParam.PeriodAlignment.convert + YPeriod0 |> DynObj.setValueOpt boxPlot "yperiod0" + Marker |> DynObj.setValueOpt boxPlot "marker" + Line |> DynObj.setValueOpt boxPlot "line" + BoxMean |> DynObj.setValueOptBy boxPlot "boxmean" StyleParam.BoxMean.convert + BoxPoints |> DynObj.setValueOptBy boxPlot "boxpoints" StyleParam.BoxPoints.convert + Notched |> DynObj.setValueOpt boxPlot "notched" + NotchWidth |> DynObj.setValueOpt boxPlot "notchwidth" + Whiskerwidth |> DynObj.setValueOpt boxPlot "whiskerwidth" + Q1 |> DynObj.setValueOpt boxPlot "q1" + Median |> DynObj.setValueOpt boxPlot "median" + Q3 |> DynObj.setValueOpt boxPlot "q3" + LowerFence |> DynObj.setValueOpt boxPlot "lowerfence" + UpperFence |> DynObj.setValueOpt boxPlot "upperfence" + NotchSpan |> DynObj.setValueOpt boxPlot "notchspan" + Mean |> DynObj.setValueOpt boxPlot "mean" + SD |> DynObj.setValueOpt boxPlot "sd" + QuartileMethod |> DynObj.setValueOptBy boxPlot "quartilemethod" StyleParam.QuartileMethod.convert + SelectedPoints |> DynObj.setValueOpt boxPlot "selectedpoints" + Selected |> DynObj.setValueOpt boxPlot "selected" + Unselected |> DynObj.setValueOpt boxPlot "unselected" + FillColor |> DynObj.setValueOpt boxPlot "fillcolor" + HoverLabel |> DynObj.setValueOpt boxPlot "hoverlabel" + HoverOn |> DynObj.setValueOptBy boxPlot "hoveron" StyleParam.HoverOn.convert + PointPos |> DynObj.setValueOpt boxPlot "pointpos" + Jitter |> DynObj.setValueOpt boxPlot "jitter" + XCalendar |> DynObj.setValueOptBy boxPlot "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy boxPlot "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt boxPlot "uirevision" // out -> boxPlot @@ -688,7 +768,7 @@ type Trace2DStyle() = X |> DynObj.setValueOpt boxPlot "x" X0 |> DynObj.setValueOpt boxPlot "x0" Y0 |> DynObj.setValueOpt boxPlot "y0" - Points |> DynObj.setValueOptBy boxPlot "points" StyleParam.Jitterpoints.convert + Points |> DynObj.setValueOptBy boxPlot "points" StyleParam.JitterPoints.convert Jitter |> DynObj.setValueOpt boxPlot "jitter" Pointpos |> DynObj.setValueOpt boxPlot "pointpos" Orientation |> DynObj.setValueOptBy boxPlot "orientation" StyleParam.Orientation.convert From b54c0232d17ca305cd918666cb60f7e39305dd3a Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 13 Oct 2021 08:40:54 +0200 Subject: [PATCH 02/11] Improve Chart.BoxPlot, add outlierwidth to marker --- src/Plotly.NET/ChartAPI/Chart2D.fs | 139 ++++++++++++------ .../Traces/ObjectAbstractions/Marker.fs | 4 + src/Plotly.NET/Traces/Trace.fs | 2 + 3 files changed, 99 insertions(+), 46 deletions(-) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 0cdcde1a6..80031b9b2 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1483,65 +1483,112 @@ module Chart2D = [] static member BoxPlot ( - [] ?x, - [] ?y, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Fillcolor, - [] ?Opacity, - [] ?Whiskerwidth, - [] ?Boxpoints, - [] ?Boxmean, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Marker, - [] ?Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Notched, - [] ?NotchWidth, - [] ?QuartileMethod + [] ?x : seq<#IConvertible>, + [] ?y : seq<#IConvertible>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?Fillcolor : Color, + [] ?MarkerColor : Color, + [] ?OutlierColor : Color, + [] ?OutlierWidth : int, + [] ?Opacity : float, + [] ?WhiskerWidth : float, + [] ?BoxPoints : StyleParam.BoxPoints, + [] ?BoxMean : StyleParam.BoxMean, + [] ?Jitter : float, + [] ?PointPos : float, + [] ?Orientation : StyleParam.Orientation, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?AlignmentGroup: string, + [] ?Offsetgroup : string, + [] ?Notched : bool, + [] ?NotchWidth : float, + [] ?QuartileMethod: StyleParam.QuartileMethod ) = Trace2D.initBoxPlot ( Trace2DStyle.BoxPlot( - ?X=x, ?Y = y, - ?Whiskerwidth=Whiskerwidth,?Boxpoints=Boxpoints, - ?Boxmean=Boxmean,?Jitter=Jitter,?Pointpos=Pointpos,?Orientation=Orientation,?Fillcolor=Fillcolor, - ?Marker=Marker,?Line=Line,?Alignmentgroup=Alignmentgroup,?Offsetgroup=Offsetgroup,?Notched=Notched,?NotchWidth=NotchWidth,?QuartileMethod=QuartileMethod + ?X = x, + ?Y = y, + ?Text = Text, + ?MultiText = MultiText, + ?Whiskerwidth = WhiskerWidth, + ?BoxPoints = BoxPoints, + ?BoxMean = BoxMean, + ?Jitter = Jitter, + ?PointPos = PointPos, + ?Orientation = Orientation, + ?FillColor = Fillcolor, + ?Marker = Marker, + ?Line = Line, + ?AlignmentGroup = AlignmentGroup, + ?OffsetGroup = Offsetgroup, + ?Notched = Notched, + ?NotchWidth = NotchWidth, + ?QuartileMethod = QuartileMethod ) ) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.Marker(?Color=Color) + |> TraceStyle.Marker(?Color=MarkerColor, ?OutlierColor=OutlierColor, ?OutlierWidth=OutlierWidth) |> GenericChart.ofTraceObject /// Displays the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. [] - static member BoxPlot(xy, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Fillcolor, - [] ?Opacity, - [] ?Whiskerwidth, - [] ?Boxpoints, - [] ?Boxmean, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Marker, - [] ?Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Notched, - [] ?NotchWidth, - [] ?QuartileMethod + static member BoxPlot( + xy: seq<#IConvertible * #IConvertible>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?Fillcolor : Color, + [] ?MarkerColor : Color, + [] ?OutlierColor : Color, + [] ?OutlierWidth : int, + [] ?Opacity : float, + [] ?WhiskerWidth : float, + [] ?BoxPoints : StyleParam.BoxPoints, + [] ?BoxMean : StyleParam.BoxMean, + [] ?Jitter : float, + [] ?PointPos : float, + [] ?Orientation : StyleParam.Orientation, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?AlignmentGroup: string, + [] ?Offsetgroup : string, + [] ?Notched : bool, + [] ?NotchWidth : float, + [] ?QuartileMethod: StyleParam.QuartileMethod ) = let x,y = Seq.unzip xy - Chart.BoxPlot(x, y, ?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Fillcolor=Fillcolor,?Opacity=Opacity,?Whiskerwidth=Whiskerwidth,?Boxpoints=Boxpoints,?Boxmean=Boxmean,?Jitter=Jitter,?Pointpos=Pointpos,?Orientation=Orientation, - ?Marker=Marker,?Line=Line,?Alignmentgroup=Alignmentgroup,?Offsetgroup=Offsetgroup,?Notched=Notched,?NotchWidth=NotchWidth,?QuartileMethod=QuartileMethod) + Chart.BoxPlot( + x, y, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Text = Text , + ?MultiText = MultiText , + ?Fillcolor = Fillcolor , + ?MarkerColor = MarkerColor , + ?OutlierColor = OutlierColor , + ?OutlierWidth = OutlierWidth , + ?Opacity = Opacity , + ?WhiskerWidth = WhiskerWidth , + ?BoxPoints = BoxPoints , + ?BoxMean = BoxMean , + ?Jitter = Jitter , + ?PointPos = PointPos , + ?Orientation = Orientation , + ?Marker = Marker , + ?Line = Line , + ?AlignmentGroup = AlignmentGroup, + ?Offsetgroup = Offsetgroup , + ?Notched = Notched , + ?NotchWidth = NotchWidth , + ?QuartileMethod = QuartileMethod + ) + /// Displays the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs index ecec4d103..0f4c5bdbf 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs @@ -33,6 +33,7 @@ type Marker () = [] ?Symbol : StyleParam.MarkerSymbol, [] ?MultiSymbol : seq, [] ?OutlierColor : Color, + [] ?OutlierWidth : int, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, [] ?ShowScale : bool, @@ -64,6 +65,7 @@ type Marker () = ?Symbol = Symbol , ?MultiSymbol = MultiSymbol , ?OutlierColor = OutlierColor , + ?OutlierWidth = OutlierWidth , ?Maxdisplayed = Maxdisplayed , ?ReverseScale = ReverseScale , ?ShowScale = ShowScale , @@ -95,6 +97,7 @@ type Marker () = [] ?Symbol : StyleParam.MarkerSymbol, [] ?MultiSymbol : seq, [] ?OutlierColor : Color, + [] ?OutlierWidth : int, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, [] ?ShowScale : bool, @@ -121,6 +124,7 @@ type Marker () = Pattern |> DynObj.setValueOpt marker "pattern" (Symbol, MultiSymbol) |> DynObj.setSingleOrMultiOptBy marker "symbol" StyleParam.MarkerSymbol.convert OutlierColor |> DynObj.setValueOpt marker "outliercolor" + OutlierWidth |> DynObj.setValueOpt marker "outlierwidth" Maxdisplayed |> DynObj.setValueOpt marker "maxdisplayed" ReverseScale |> DynObj.setValueOpt marker "reversescale" ShowScale |> DynObj.setValueOpt marker "showscale" diff --git a/src/Plotly.NET/Traces/Trace.fs b/src/Plotly.NET/Traces/Trace.fs index eb5fce9db..562f6b225 100644 --- a/src/Plotly.NET/Traces/Trace.fs +++ b/src/Plotly.NET/Traces/Trace.fs @@ -156,6 +156,7 @@ type TraceStyle() = [] ?Symbol : StyleParam.MarkerSymbol, [] ?MultiSymbol : seq, [] ?OutlierColor : Color, + [] ?OutlierWidth : int, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, [] ?ShowScale : bool, @@ -189,6 +190,7 @@ type TraceStyle() = ?Symbol = Symbol , ?MultiSymbol = MultiSymbol , ?OutlierColor = OutlierColor , + ?OutlierWidth = OutlierWidth , ?Maxdisplayed = Maxdisplayed , ?ReverseScale = ReverseScale , ?ShowScale = ShowScale , From f99840207cd8025a71d6329932027e0a1c8958a2 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 13 Oct 2021 09:33:56 +0200 Subject: [PATCH 03/11] Add all violin trace params, improve Chart function --- src/Plotly.NET/ChartAPI/Chart2D.fs | 243 +++++++++++------- .../CommonAbstractions/StyleParams.fs | 40 +++ src/Plotly.NET/Plotly.NET.fsproj | 2 +- .../Traces/ObjectAbstractions/Box.fs | 23 +- .../Traces/ObjectAbstractions/Meanline.fs | 8 +- src/Plotly.NET/Traces/Trace2D.fs | 166 +++++++----- 6 files changed, 319 insertions(+), 163 deletions(-) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 80031b9b2..b6c4a7435 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1537,8 +1537,9 @@ module Chart2D = /// Displays the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. [] - static member BoxPlot( - xy: seq<#IConvertible * #IConvertible>, + static member BoxPlot + ( + xy: seq<#IConvertible * #IConvertible>, [] ?Name : string, [] ?ShowLegend : bool, [] ?Text : #IConvertible, @@ -1561,33 +1562,34 @@ module Chart2D = [] ?Notched : bool, [] ?NotchWidth : float, [] ?QuartileMethod: StyleParam.QuartileMethod - ) = - let x,y = Seq.unzip xy - Chart.BoxPlot( - x, y, - ?Name = Name , - ?ShowLegend = ShowLegend , - ?Text = Text , - ?MultiText = MultiText , - ?Fillcolor = Fillcolor , - ?MarkerColor = MarkerColor , - ?OutlierColor = OutlierColor , - ?OutlierWidth = OutlierWidth , - ?Opacity = Opacity , - ?WhiskerWidth = WhiskerWidth , - ?BoxPoints = BoxPoints , - ?BoxMean = BoxMean , - ?Jitter = Jitter , - ?PointPos = PointPos , - ?Orientation = Orientation , - ?Marker = Marker , - ?Line = Line , - ?AlignmentGroup = AlignmentGroup, - ?Offsetgroup = Offsetgroup , - ?Notched = Notched , - ?NotchWidth = NotchWidth , - ?QuartileMethod = QuartileMethod - ) + + ) = + let x,y = Seq.unzip xy + Chart.BoxPlot( + x, y, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Text = Text , + ?MultiText = MultiText , + ?Fillcolor = Fillcolor , + ?MarkerColor = MarkerColor , + ?OutlierColor = OutlierColor , + ?OutlierWidth = OutlierWidth , + ?Opacity = Opacity , + ?WhiskerWidth = WhiskerWidth , + ?BoxPoints = BoxPoints , + ?BoxMean = BoxMean , + ?Jitter = Jitter , + ?PointPos = PointPos , + ?Orientation = Orientation , + ?Marker = Marker , + ?Line = Line , + ?AlignmentGroup = AlignmentGroup, + ?Offsetgroup = Offsetgroup , + ?Notched = Notched , + ?NotchWidth = NotchWidth , + ?QuartileMethod = QuartileMethod + ) @@ -1595,77 +1597,142 @@ module Chart2D = [] static member Violin ( - [] ?x, - [] ?y, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Fillcolor, - [] ?Opacity, - [] ?Points, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Width, - [] ?Marker, - [] ?Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Box, - [] ?Bandwidth, - [] ?Meanline, - [] ?Scalegroup, - [] ?Scalemode, - [] ?Side, - [] ?Span, - [] ?SpanMode, - [] ?Uirevision + [] ?X : seq<#IConvertible>, + [] ?Y : seq<#IConvertible>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?FillColor : Color, + [] ?Opacity : float, + [] ?Points : StyleParam.BoxPoints, + [] ?Jitter : float, + [] ?PointPos : float, + [] ?Orientation : StyleParam.Orientation, + [] ?Width : float, + [] ?MarkerColor : Color, + [] ?OutlierColor : Color, + [] ?OutlierWidth : int, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?AlignmentGroup: string, + [] ?OffsetGroup : string, + [] ?ShowBox : bool, + [] ?BoxWidth : float, + [] ?BoxFillColor : Color, + [] ?Box : Box, + [] ?BandWidth : float, + [] ?MeanLine : MeanLine, + [] ?ScaleGroup : string, + [] ?ScaleMode : StyleParam.ScaleMode, + [] ?Side : StyleParam.ViolinSide, + [] ?Span : StyleParam.Range, + [] ?SpanMode : StyleParam.SpanMode ) = + + let box = + Box + |> Option.defaultValue (TraceObjects.Box.init()) + |> TraceObjects.Box.style ( + ?Visible = ShowBox , + ?Width = BoxWidth , + ?FillColor = BoxFillColor + ) + Trace2D.initViolin ( Trace2DStyle.Violin( - ?X=x, ?Y = y,?Points=Points, - ?Jitter=Jitter,?Pointpos=Pointpos,?Orientation=Orientation,?Fillcolor=Fillcolor, - ?Width=Width,?Marker=Marker,?Line=Line,?Alignmentgroup=Alignmentgroup,?Offsetgroup=Offsetgroup,?Box=Box,?Bandwidth=Bandwidth,?Meanline=Meanline, - ?Scalegroup=Scalegroup,?Scalemode=Scalemode,?Side=Side,?Span=Span,?SpanMode=SpanMode,?Uirevision=Uirevision + ?X = X , + ?Y = Y , + ?Name = Name , + ?ShowLegend = ShowLegend , + ?FillColor = FillColor , + ?Opacity = Opacity , + ?Points = Points , + ?Jitter = Jitter , + ?PointPos = PointPos , + ?Orientation = Orientation , + ?Width = Width , + ?Marker = Marker , + ?Line = Line , + ?AlignmentGroup = AlignmentGroup, + ?OffsetGroup = OffsetGroup , + Box = box , + ?BandWidth = BandWidth , + ?MeanLine = MeanLine , + ?ScaleGroup = ScaleGroup , + ?ScaleMode = ScaleMode , + ?Side = Side , + ?Span = Span , + ?SpanMode = SpanMode ) ) - |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.Marker(?Color=Color) + |> TraceStyle.TraceInfo(?Name=Name, ?ShowLegend=ShowLegend, ?Opacity=Opacity) + |> TraceStyle.Marker(?Color=MarkerColor, ?OutlierColor= OutlierColor, ?OutlierWidth= OutlierWidth) |> GenericChart.ofTraceObject /// Displays the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum. [] - static member Violin(xy, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Fillcolor, - [] ?Opacity, - [] ?Points, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Width, - [] ?Marker, - [] ?Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Box, - [] ?Bandwidth, - [] ?Meanline, - [] ?Scalegroup, - [] ?Scalemode, - [] ?Side, - [] ?Span, - [] ?SpanMode, - [] ?Uirevision + static member Violin + ( + xy: seq<#IConvertible * #IConvertible>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?FillColor : Color, + [] ?Opacity : float, + [] ?Points : StyleParam.BoxPoints, + [] ?Jitter : float, + [] ?PointPos : float, + [] ?Orientation : StyleParam.Orientation, + [] ?Width : float, + [] ?MarkerColor : Color, + [] ?OutlierColor : Color, + [] ?OutlierWidth : int, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?AlignmentGroup: string, + [] ?OffsetGroup : string, + [] ?ShowBox : bool, + [] ?BoxWidth : float, + [] ?BoxFillColor : Color, + [] ?Box : Box, + [] ?BandWidth : float, + [] ?MeanLine : MeanLine, + [] ?ScaleGroup : string, + [] ?ScaleMode : StyleParam.ScaleMode, + [] ?Side : StyleParam.ViolinSide, + [] ?Span : StyleParam.Range, + [] ?SpanMode : StyleParam.SpanMode ) = let x,y = Seq.unzip xy - Chart.Violin(x, y, ?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Fillcolor=Fillcolor,?Opacity=Opacity,?Points=Points,?Jitter=Jitter,?Pointpos=Pointpos,?Orientation=Orientation, - ?Width=Width,?Marker=Marker,?Line=Line,?Alignmentgroup=Alignmentgroup,?Offsetgroup=Offsetgroup,?Box=Box,?Bandwidth=Bandwidth,?Meanline=Meanline, - ?Scalegroup=Scalegroup,?Scalemode=Scalemode,?Side=Side,?Span=Span,?SpanMode=SpanMode,?Uirevision=Uirevision - ) + Chart.Violin( + x, y, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?FillColor = FillColor , + ?Opacity = Opacity , + ?Points = Points , + ?Jitter = Jitter , + ?PointPos = PointPos , + ?Orientation = Orientation , + ?Width = Width , + ?MarkerColor = MarkerColor , + ?OutlierColor = OutlierColor , + ?OutlierWidth = OutlierWidth , + ?Marker = Marker , + ?Line = Line , + ?AlignmentGroup= AlignmentGroup, + ?OffsetGroup = OffsetGroup , + ?ShowBox = ShowBox , + ?BoxWidth = BoxWidth , + ?BoxFillColor = BoxFillColor , + ?Box = Box , + ?BandWidth = BandWidth , + ?MeanLine = MeanLine , + ?ScaleGroup = ScaleGroup , + ?ScaleMode = ScaleMode , + ?Side = Side , + ?Span = Span , + ?SpanMode = SpanMode + ) /// Computes the bi-dimensional histogram of two data samples and auto-determines the bin size. diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index d7f98045b..f3a8085d0 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -1850,6 +1850,33 @@ module StyleParam = // #S# //-------------------------- + [] + type SpanMode = + | Soft | Hard | Manual + + static member toString = function + | Soft -> "soft" + | Hard -> "hard" + | Manual-> "manual" + + + static member convert = SpanMode.toString >> box + override this.ToString() = this |> SpanMode.toString + member this.Convert() = this |> SpanMode.convert + + [] + type ScaleMode = + | Width | Count + + static member toString = function + | Width -> "width" + | Count -> "count" + + + static member convert = ScaleMode.toString >> box + override this.ToString() = this |> ScaleMode.toString + member this.Convert() = this |> ScaleMode.convert + [] type StackGaps = | InferZero | Interpolate @@ -2608,6 +2635,19 @@ module StyleParam = // #V# //-------------------------- + [] + type ViolinSide = + | Both | Positive | Negative + + static member toString = function + | Both -> "both" + | Positive -> "positive" + | Negative -> "negative" + + static member convert = ViolinSide.toString >> box + override this.ToString() = this |> ViolinSide.toString + member this.Convert() = this |> ViolinSide.convert + [] type ViolinMode = | Group | Overlay diff --git a/src/Plotly.NET/Plotly.NET.fsproj b/src/Plotly.NET/Plotly.NET.fsproj index de45afdd3..37c30bb97 100644 --- a/src/Plotly.NET/Plotly.NET.fsproj +++ b/src/Plotly.NET/Plotly.NET.fsproj @@ -95,7 +95,7 @@ - + diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Box.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Box.fs index d6e7f7511..f6ae912b4 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Box.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Box.fs @@ -16,15 +16,17 @@ type Box () = [] ?Visible: bool, [] ?Width: float, [] ?FillColor: Color, - [] ?Line: Line + [] ?LineColor: Color, + [] ?LineWidth: float ) = Box () |> Box.style ( - ?Visible = Visible, - ?Width = Width, - ?FillColor = FillColor, - ?Line = Line + ?Visible = Visible, + ?Width = Width, + ?FillColor = FillColor, + ?LineColor = LineColor, + ?LineWidth = LineWidth ) @@ -34,13 +36,20 @@ type Box () = [] ?Visible: bool, [] ?Width: float, [] ?FillColor: Color, - [] ?Line: Line + [] ?LineColor: Color, + [] ?LineWidth: float ) = (fun (box:Box) -> + + let line = + if LineColor.IsSome || LineWidth.IsSome then + Some (Line.init(?Color = LineColor, ?Width = LineWidth)) + else None + Visible |> DynObj.setValueOpt box "visible" Width |> DynObj.setValueOpt box "width" FillColor |> DynObj.setValueOpt box "fillColor" - Line |> DynObj.setValueOpt box "line" + line |> DynObj.setValueOpt box "line" // out -> box diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs index 4e1a55e58..fe9ce7412 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs @@ -7,7 +7,7 @@ open System open System.Runtime.InteropServices /// Meanline type inherits from dynamic object (parent violin) -type Meanline () = +type MeanLine () = inherit DynamicObj () /// Initialized Line object @@ -17,8 +17,8 @@ type Meanline () = [] ?Color: Color, [] ?Width: float ) = - Meanline () - |> Meanline.style + MeanLine () + |> MeanLine.style ( ?Visible = Visible, ?Color = Color , @@ -33,7 +33,7 @@ type Meanline () = [] ?Color: Color, [] ?Width: float ) = - (fun (line:Meanline) -> + (fun (line:MeanLine) -> Visible |> DynObj.setValueOpt line "visible" Color |> DynObj.setValueOpt line "color" Width |> DynObj.setValueOpt line "width" diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index be124b78e..9c523f6ff 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -733,71 +733,111 @@ type Trace2DStyle() = // Applies the styles of violin plot plot to TraceObjects static member Violin ( - [] ?Y, - [] ?X, - [] ?X0, - [] ?Y0, - [] ?Width, - [] ?Marker:Marker, - [] ?Line:Line, - [] ?Alignmentgroup, - [] ?Offsetgroup, - [] ?Box:Box, - [] ?Bandwidth, - [] ?Meanline:Meanline, - [] ?Scalegroup, - [] ?Scalemode, - [] ?Side, - [] ?Span, - [] ?SpanMode, - [] ?Uirevision, - [] ?Points, - [] ?Jitter, - [] ?Pointpos, - [] ?Orientation, - [] ?Fillcolor: Color, - [] ?xAxis, - [] ?yAxis, - [] ?Ysrc, - [] ?Xsrc + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?X0 : #IConvertible, + [] ?DX : #IConvertible, + [] ?Y : seq<#IConvertible>, + [] ?Y0 : #IConvertible, + [] ?DY : #IConvertible, + [] ?Width : float, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HoverText : string, + [] ?MultiHoverText : seq, + [] ?HoverInfo : StyleParam.HoverInfo, + [] ?HoverTemplate : string, + [] ?MultiHoverTemplate: seq, + [] ?XHoverFormat : string, + [] ?YHoverFormat : string, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Orientation : StyleParam.Orientation, + [] ?AlignmentGroup : string, + [] ?OffsetGroup : string, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?Box : Box, + [] ?SelectedPoints : seq<#IConvertible>, + [] ?Selected : Selection, + [] ?Unselected : Selection, + [] ?BandWidth : float, + [] ?FillColor : Color, + [] ?HoverLabel : Hoverlabel, + [] ?HoverOn : StyleParam.HoverOn, + [] ?PointPos : float, + [] ?Jitter : float, + [] ?MeanLine : MeanLine, + [] ?Points : StyleParam.BoxPoints, + [] ?ScaleGroup : string, + [] ?ScaleMode : StyleParam.ScaleMode, + [] ?Side : StyleParam.ViolinSide, + [] ?Span : StyleParam.Range, + [] ?SpanMode : StyleParam.SpanMode, + [] ?UIRevision : string ) = - (fun (boxPlot:('T :> Trace)) -> - - Y |> DynObj.setValueOpt boxPlot "y" - X |> DynObj.setValueOpt boxPlot "x" - X0 |> DynObj.setValueOpt boxPlot "x0" - Y0 |> DynObj.setValueOpt boxPlot "y0" - Points |> DynObj.setValueOptBy boxPlot "points" StyleParam.JitterPoints.convert - Jitter |> DynObj.setValueOpt boxPlot "jitter" - Pointpos |> DynObj.setValueOpt boxPlot "pointpos" - Orientation |> DynObj.setValueOptBy boxPlot "orientation" StyleParam.Orientation.convert - Fillcolor |> DynObj.setValueOpt boxPlot "fillcolor" - - Width |> DynObj.setValueOpt boxPlot "width" - Marker |> DynObj.setValueOpt boxPlot "marker" - Line |> DynObj.setValueOpt boxPlot "line" - Alignmentgroup |> DynObj.setValueOpt boxPlot "alignmentgroup" - Offsetgroup |> DynObj.setValueOpt boxPlot "offsetgroup" - - Box |> DynObj.setValueOpt boxPlot "box" - Bandwidth |> DynObj.setValueOpt boxPlot "bandwidth" - Meanline |> DynObj.setValueOpt boxPlot "meanline" - Scalegroup |> DynObj.setValueOpt boxPlot "scalegroup" - Scalemode |> DynObj.setValueOpt boxPlot "scalemode" - Side |> DynObj.setValueOpt boxPlot "side" - Span |> DynObj.setValueOpt boxPlot "span" - SpanMode |> DynObj.setValueOpt boxPlot "spanmode" - Uirevision |> DynObj.setValueOpt boxPlot "uirevision" - - - xAxis |> DynObj.setValueOpt boxPlot "xaxis" - yAxis |> DynObj.setValueOpt boxPlot "yaxis" - Ysrc |> DynObj.setValueOpt boxPlot "ysrc" - Xsrc |> DynObj.setValueOpt boxPlot "xsrc" - - // out -> - boxPlot + (fun (violin:('T :> Trace)) -> + + Name |> DynObj.setValueOpt violin "Name" + Visible |> DynObj.setValueOptBy violin "Visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt violin "ShowLegend" + LegendRank |> DynObj.setValueOpt violin "LegendRank" + LegendGroup |> DynObj.setValueOpt violin "LegendGroup" + LegendGroupTitle |> DynObj.setValueOpt violin "LegendGroupTitle" + Opacity |> DynObj.setValueOpt violin "Opacity" + Ids |> DynObj.setValueOpt violin "Ids" + X |> DynObj.setValueOpt violin "X" + X0 |> DynObj.setValueOpt violin "X0" + DX |> DynObj.setValueOpt violin "DX" + Y |> DynObj.setValueOpt violin "Y" + Y0 |> DynObj.setValueOpt violin "Y0" + DY |> DynObj.setValueOpt violin "DY" + Width |> DynObj.setValueOpt violin "Width" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt violin "text" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt violin "hovertext" + HoverInfo |> DynObj.setValueOptBy violin "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt violin "hovertemplate" + XHoverFormat |> DynObj.setValueOpt violin "XHoverFormat" + YHoverFormat |> DynObj.setValueOpt violin "YHoverFormat" + Meta |> DynObj.setValueOpt violin "Meta" + CustomData |> DynObj.setValueOpt violin "CustomData" + XAxis |> DynObj.setValueOptBy violin "XAxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy violin "YAxis" StyleParam.LinearAxisId.convert + Orientation |> DynObj.setValueOptBy violin "Orientation" StyleParam.Orientation.convert + AlignmentGroup |> DynObj.setValueOpt violin "AlignmentGroup" + OffsetGroup |> DynObj.setValueOpt violin "OffsetGroup" + Marker |> DynObj.setValueOpt violin "Marker" + Line |> DynObj.setValueOpt violin "Line" + Box |> DynObj.setValueOpt violin "Box" + SelectedPoints |> DynObj.setValueOpt violin "SelectedPoints" + Selected |> DynObj.setValueOpt violin "Selected" + Unselected |> DynObj.setValueOpt violin "Unselected" + BandWidth |> DynObj.setValueOpt violin "BandWidth" + FillColor |> DynObj.setValueOpt violin "FillColor" + HoverLabel |> DynObj.setValueOpt violin "HoverLabel" + HoverOn |> DynObj.setValueOptBy violin "HoverOn" StyleParam.HoverOn.convert + PointPos |> DynObj.setValueOpt violin "PointPos" + Jitter |> DynObj.setValueOpt violin "Jitter" + MeanLine |> DynObj.setValueOpt violin "MeanLine" + Points |> DynObj.setValueOptBy violin "Points" StyleParam.BoxPoints.convert + ScaleGroup |> DynObj.setValueOpt violin "ScaleGroup" + ScaleMode |> DynObj.setValueOptBy violin "ScaleMode" StyleParam.ScaleMode.convert + Side |> DynObj.setValueOptBy violin "Side" StyleParam.ViolinSide.convert + Span |> DynObj.setValueOptBy violin "Span" StyleParam.Range.convert + SpanMode |> DynObj.setValueOptBy violin "SpanMode" StyleParam.SpanMode.convert + UIRevision |> DynObj.setValueOpt violin "UIRevision" + + violin ) From eb00fc0dfbea2649329864903b846d56bd5e49d6 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 13 Oct 2021 10:07:12 +0200 Subject: [PATCH 04/11] Fix tests, some violin props --- src/Plotly.NET/ChartAPI/Chart2D.fs | 4 +- src/Plotly.NET/Playground.fsx | 35 +++++++- src/Plotly.NET/Traces/Trace2D.fs | 90 +++++++++---------- .../HtmlCodegen/ChartLayout.fs | 12 +-- .../HtmlCodegen/DistributionCharts.fs | 30 +++---- 5 files changed, 102 insertions(+), 69 deletions(-) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index b6c4a7435..da53e7be2 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1603,7 +1603,7 @@ module Chart2D = [] ?ShowLegend : bool, [] ?FillColor : Color, [] ?Opacity : float, - [] ?Points : StyleParam.BoxPoints, + [] ?Points : StyleParam.JitterPoints, [] ?Jitter : float, [] ?PointPos : float, [] ?Orientation : StyleParam.Orientation, @@ -1678,7 +1678,7 @@ module Chart2D = [] ?ShowLegend : bool, [] ?FillColor : Color, [] ?Opacity : float, - [] ?Points : StyleParam.BoxPoints, + [] ?Points : StyleParam.JitterPoints, [] ?Jitter : float, [] ?PointPos : float, [] ?Orientation : StyleParam.Orientation, diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index dbc2f5a8a..b8128b5ff 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -87,7 +87,7 @@ #load "WaterfallConnector.fs" #load "FunnelConnector.fs" #load "Box.fs" -#load "Meanline.fs" +#load "MeanLine.fs" #load "Bins.fs" #load "Cumulative.fs" #load "Error.fs" @@ -161,6 +161,39 @@ open FSharpAux open System open System.IO + +let violin1Chart = + let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] + let x = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] + Chart.Violin ( + x,y, + Points=StyleParam.JitterPoints.All + ) + +let violin2Chart = + let x = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] + let y = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] + Chart.Violin( + x,y, + Jitter=0.1, + Points=StyleParam.JitterPoints.All, + Orientation=StyleParam.Orientation.Horizontal, + MeanLine=MeanLine.init(Visible=true) + ) + +let violin3Chart = + let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] + 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.] + [ + Chart.Violin ("y" ,y,Name="bin1",Jitter=0.1,Points=StyleParam.JitterPoints.All); + Chart.Violin ("y'",y',Name="bin2",Jitter=0.1,Points=StyleParam.JitterPoints.All); + ] + |> Chart.combine + +violin1Chart |> Chart.show +violin2Chart |> Chart.show +violin3Chart |> Chart.show + let character = ["Eve"; "Cain"; "Seth"; "Enos"; "Noam"; "Abel"; "Awan"; "Enoch"; "Azura"] let parent = [""; "Eve"; "Eve"; "Seth"; "Seth"; "Eve"; "Eve"; "Awan"; "Eve" ] diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index 9c523f6ff..5878767d3 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -777,7 +777,7 @@ type Trace2DStyle() = [] ?PointPos : float, [] ?Jitter : float, [] ?MeanLine : MeanLine, - [] ?Points : StyleParam.BoxPoints, + [] ?Points : StyleParam.JitterPoints, [] ?ScaleGroup : string, [] ?ScaleMode : StyleParam.ScaleMode, [] ?Side : StyleParam.ViolinSide, @@ -788,54 +788,54 @@ type Trace2DStyle() = ) = (fun (violin:('T :> Trace)) -> - Name |> DynObj.setValueOpt violin "Name" - Visible |> DynObj.setValueOptBy violin "Visible" StyleParam.Visible.convert - ShowLegend |> DynObj.setValueOpt violin "ShowLegend" - LegendRank |> DynObj.setValueOpt violin "LegendRank" - LegendGroup |> DynObj.setValueOpt violin "LegendGroup" - LegendGroupTitle |> DynObj.setValueOpt violin "LegendGroupTitle" - Opacity |> DynObj.setValueOpt violin "Opacity" - Ids |> DynObj.setValueOpt violin "Ids" - X |> DynObj.setValueOpt violin "X" - X0 |> DynObj.setValueOpt violin "X0" - DX |> DynObj.setValueOpt violin "DX" - Y |> DynObj.setValueOpt violin "Y" - Y0 |> DynObj.setValueOpt violin "Y0" - DY |> DynObj.setValueOpt violin "DY" - Width |> DynObj.setValueOpt violin "Width" + Name |> DynObj.setValueOpt violin "name" + Visible |> DynObj.setValueOptBy violin "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt violin "showlegend" + LegendRank |> DynObj.setValueOpt violin "legendrank" + LegendGroup |> DynObj.setValueOpt violin "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt violin "legendgrouptitle" + Opacity |> DynObj.setValueOpt violin "opacity" + Ids |> DynObj.setValueOpt violin "ids" + X |> DynObj.setValueOpt violin "x" + X0 |> DynObj.setValueOpt violin "x0" + DX |> DynObj.setValueOpt violin "dx" + Y |> DynObj.setValueOpt violin "y" + Y0 |> DynObj.setValueOpt violin "y0" + DY |> DynObj.setValueOpt violin "dy" + Width |> DynObj.setValueOpt violin "width" (Text, MultiText) |> DynObj.setSingleOrMultiOpt violin "text" (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt violin "hovertext" HoverInfo |> DynObj.setValueOptBy violin "hoverinfo" StyleParam.HoverInfo.convert (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt violin "hovertemplate" - XHoverFormat |> DynObj.setValueOpt violin "XHoverFormat" - YHoverFormat |> DynObj.setValueOpt violin "YHoverFormat" - Meta |> DynObj.setValueOpt violin "Meta" - CustomData |> DynObj.setValueOpt violin "CustomData" - XAxis |> DynObj.setValueOptBy violin "XAxis" StyleParam.LinearAxisId.convert - YAxis |> DynObj.setValueOptBy violin "YAxis" StyleParam.LinearAxisId.convert - Orientation |> DynObj.setValueOptBy violin "Orientation" StyleParam.Orientation.convert - AlignmentGroup |> DynObj.setValueOpt violin "AlignmentGroup" - OffsetGroup |> DynObj.setValueOpt violin "OffsetGroup" - Marker |> DynObj.setValueOpt violin "Marker" - Line |> DynObj.setValueOpt violin "Line" - Box |> DynObj.setValueOpt violin "Box" - SelectedPoints |> DynObj.setValueOpt violin "SelectedPoints" - Selected |> DynObj.setValueOpt violin "Selected" - Unselected |> DynObj.setValueOpt violin "Unselected" - BandWidth |> DynObj.setValueOpt violin "BandWidth" - FillColor |> DynObj.setValueOpt violin "FillColor" - HoverLabel |> DynObj.setValueOpt violin "HoverLabel" - HoverOn |> DynObj.setValueOptBy violin "HoverOn" StyleParam.HoverOn.convert - PointPos |> DynObj.setValueOpt violin "PointPos" - Jitter |> DynObj.setValueOpt violin "Jitter" - MeanLine |> DynObj.setValueOpt violin "MeanLine" - Points |> DynObj.setValueOptBy violin "Points" StyleParam.BoxPoints.convert - ScaleGroup |> DynObj.setValueOpt violin "ScaleGroup" - ScaleMode |> DynObj.setValueOptBy violin "ScaleMode" StyleParam.ScaleMode.convert - Side |> DynObj.setValueOptBy violin "Side" StyleParam.ViolinSide.convert - Span |> DynObj.setValueOptBy violin "Span" StyleParam.Range.convert - SpanMode |> DynObj.setValueOptBy violin "SpanMode" StyleParam.SpanMode.convert - UIRevision |> DynObj.setValueOpt violin "UIRevision" + XHoverFormat |> DynObj.setValueOpt violin "xhoverformat" + YHoverFormat |> DynObj.setValueOpt violin "yhoverformat" + Meta |> DynObj.setValueOpt violin "meta" + CustomData |> DynObj.setValueOpt violin "customdata" + XAxis |> DynObj.setValueOptBy violin "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy violin "yaxis" StyleParam.LinearAxisId.convert + Orientation |> DynObj.setValueOptBy violin "orientation" StyleParam.Orientation.convert + AlignmentGroup |> DynObj.setValueOpt violin "alignmentgroup" + OffsetGroup |> DynObj.setValueOpt violin "offsetgroup" + Marker |> DynObj.setValueOpt violin "marker" + Line |> DynObj.setValueOpt violin "line" + Box |> DynObj.setValueOpt violin "box" + SelectedPoints |> DynObj.setValueOpt violin "selectedpoints" + Selected |> DynObj.setValueOpt violin "selected" + Unselected |> DynObj.setValueOpt violin "unselected" + BandWidth |> DynObj.setValueOpt violin "bandwidth" + FillColor |> DynObj.setValueOpt violin "fillcolor" + HoverLabel |> DynObj.setValueOpt violin "hoverlabel" + HoverOn |> DynObj.setValueOptBy violin "hoveron" StyleParam.HoverOn.convert + PointPos |> DynObj.setValueOpt violin "pointpos" + Jitter |> DynObj.setValueOpt violin "jitter" + MeanLine |> DynObj.setValueOpt violin "meanline" + Points |> DynObj.setValueOptBy violin "points" StyleParam.JitterPoints.convert + ScaleGroup |> DynObj.setValueOpt violin "scalegroup" + ScaleMode |> DynObj.setValueOptBy violin "scalemode" StyleParam.ScaleMode.convert + Side |> DynObj.setValueOptBy violin "side" StyleParam.ViolinSide.convert + Span |> DynObj.setValueOptBy violin "span" StyleParam.Range.convert + SpanMode |> DynObj.setValueOptBy violin "spanmode" StyleParam.SpanMode.convert + UIRevision |> DynObj.setValueOpt violin "uirevision" violin ) diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs index fc0876ecc..2365db881 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs @@ -168,8 +168,8 @@ let multiTraceGrid = [ // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) 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.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine ] @@ -187,8 +187,8 @@ let multiTraceSingleStack = [ // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) 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.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine ] @@ -211,7 +211,7 @@ let ``Multicharts and subplots`` = |> chartGeneratedContains subPlotChart ); testCase "MultiTrace Subplot grid data" ( fun () -> - """var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"subplot":"ternary2"},{"type":"heatmap","z":[[1,2],[3,4]],"showscale":false,"xaxis":"x3","yaxis":"y3"},{"type":"scatter3d","mode":"markers","x":[1],"y":[3],"z":[2],"line":{},"marker":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lon":[1],"lat":[2],"line":{},"marker":{},"subplot":"mapbox5"},{"type":"box","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"x":"y","boxpoints":"all","jitter":0.1,"name":"bin1","marker":{},"xaxis":"x6","yaxis":"y6"},{"type":"box","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"x":"y'","boxpoints":"all","jitter":0.1,"name":"bin2","marker":{},"xaxis":"x6","yaxis":"y6"}];""" + """var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"subplot":"ternary2"},{"type":"heatmap","z":[[1,2],[3,4]],"showscale":false,"xaxis":"x3","yaxis":"y3"},{"type":"scatter3d","mode":"markers","x":[1],"y":[3],"z":[2],"line":{},"marker":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lon":[1],"lat":[2],"line":{},"marker":{},"subplot":"mapbox5"},{"type":"box","x":"y","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin1","marker":{},"xaxis":"x6","yaxis":"y6"},{"type":"box","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin2","marker":{},"xaxis":"x6","yaxis":"y6"}];""" |> chartGeneratedContains multiTraceGrid ); testCase "MultiTrace Subplot grid layout" ( fun () -> @@ -228,7 +228,7 @@ let ``Multicharts and subplots`` = ); testCase "MultiTrace Single Stack data" ( fun () -> - """var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"subplot":"ternary2"},{"type":"heatmap","z":[[1,2],[3,4]],"showscale":false,"xaxis":"x3","yaxis":"y3"},{"type":"scatter3d","mode":"markers","x":[1],"y":[3],"z":[2],"line":{},"marker":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lon":[1],"lat":[2],"line":{},"marker":{},"subplot":"mapbox5"},{"type":"box","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"x":"y","boxpoints":"all","jitter":0.1,"name":"bin1","marker":{},"xaxis":"x6","yaxis":"y6"},{"type":"box","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"x":"y'","boxpoints":"all","jitter":0.1,"name":"bin2","marker":{},"xaxis":"x6","yaxis":"y6"}];""" + """var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"subplot":"ternary2"},{"type":"heatmap","z":[[1,2],[3,4]],"showscale":false,"xaxis":"x3","yaxis":"y3"},{"type":"scatter3d","mode":"markers","x":[1],"y":[3],"z":[2],"line":{},"marker":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lon":[1],"lat":[2],"line":{},"marker":{},"subplot":"mapbox5"},{"type":"box","x":"y","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin1","marker":{},"xaxis":"x6","yaxis":"y6"},{"type":"box","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin2","marker":{},"xaxis":"x6","yaxis":"y6"}];""" |> chartGeneratedContains multiTraceSingleStack ); testCase "MultiTrace Single Stack layout" ( fun () -> diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs index 7f19ec381..32f175e93 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs @@ -36,19 +36,19 @@ let ``Histogram charts`` = let box1Chart = let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] let x = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] - Chart.BoxPlot(x,y,Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All) + Chart.BoxPlot(x,y,Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All) let box2Chart = let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] let x = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] - Chart.BoxPlot(y,x,Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All,Orientation=StyleParam.Orientation.Horizontal) + Chart.BoxPlot(y,x,Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All,Orientation=StyleParam.Orientation.Horizontal) let box3Chart = let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] 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.] [ - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine @@ -56,21 +56,21 @@ let box3Chart = let ``Box charts`` = testList "DistributionCharts.Box charts" [ testCase "Box1 data" ( fun () -> - "var data = [{\"type\":\"box\",\"y\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":[\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin1\",\"bin2\",\"bin1\"],\"boxpoints\":\"all\",\"jitter\":0.1,\"marker\":{}}];" + """var data = [{"type":"box","x":["bin1","bin2","bin1","bin2","bin1","bin2","bin1","bin1","bin2","bin1"],"y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"marker":{}}];""" |> chartGeneratedContains box1Chart ); testCase "Box1 layout" ( fun () -> emptyLayout box1Chart ); testCase "Box2 data" ( fun () -> - "var data = [{\"type\":\"box\",\"y\":[\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin1\",\"bin2\",\"bin1\"],\"x\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"boxpoints\":\"all\",\"jitter\":0.1,\"orientation\":\"h\",\"marker\":{}}];" + """var data = [{"type":"box","x":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"y":["bin1","bin2","bin1","bin2","bin1","bin2","bin1","bin1","bin2","bin1"],"orientation":"h","boxpoints":"all","jitter":0.1,"marker":{}}];""" |> chartGeneratedContains box2Chart ); testCase "Box2 layout" ( fun () -> emptyLayout box2Chart ); testCase "Box3 data" ( fun () -> - "var data = [{\"type\":\"box\",\"y\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":\"y\",\"boxpoints\":\"all\",\"jitter\":0.1,\"name\":\"bin1\",\"marker\":{}},{\"type\":\"box\",\"y\":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":\"y'\",\"boxpoints\":\"all\",\"jitter\":0.1,\"name\":\"bin2\",\"marker\":{}}];" + """ar data = [{"type":"box","x":"y","y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin1","marker":{}},{"type":"box","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"boxpoints":"all","jitter":0.1,"name":"bin2","marker":{}}];""" |> chartGeneratedContains box3Chart ); testCase "Box3 layout" ( fun () -> @@ -84,7 +84,7 @@ let violin1Chart = let x = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] Chart.Violin ( x,y, - Points=StyleParam.Jitterpoints.All + Points=StyleParam.JitterPoints.All ) let violin2Chart = @@ -93,17 +93,17 @@ let violin2Chart = Chart.Violin( y,x, Jitter=0.1, - Points=StyleParam.Jitterpoints.All, + Points=StyleParam.JitterPoints.All, Orientation=StyleParam.Orientation.Horizontal, - Meanline=Meanline.init(Visible=true) + MeanLine=MeanLine.init(Visible=true) ) let violin3Chart = let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] 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.] [ - Chart.Violin ("y" ,y,Name="bin1",Jitter=0.1,Points=StyleParam.Jitterpoints.All); - Chart.Violin ("y'",y',Name="bin2",Jitter=0.1,Points=StyleParam.Jitterpoints.All); + Chart.Violin ("y" ,y,Name="bin1",Jitter=0.1,Points=StyleParam.JitterPoints.All); + Chart.Violin ("y'",y',Name="bin2",Jitter=0.1,Points=StyleParam.JitterPoints.All); ] |> Chart.combine @@ -111,21 +111,21 @@ let violin3Chart = let ``Violin charts`` = testList "DistributionCharts.Violin charts" [ testCase "Violin1 data" ( fun () -> - "var data = [{\"type\":\"violin\",\"y\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":[\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin1\",\"bin2\",\"bin1\"],\"points\":\"all\",\"marker\":{}}];" + """var data = [{"type":"violin","x":["bin1","bin2","bin1","bin2","bin1","bin2","bin1","bin1","bin2","bin1"],"y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"box":{},"points":"all","marker":{}}];""" |> chartGeneratedContains violin1Chart ); testCase "Violin1 layout" ( fun () -> emptyLayout violin1Chart ); testCase "Violin2 data" ( fun () -> - "var data = [{\"type\":\"violin\",\"y\":[\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin2\",\"bin1\",\"bin1\",\"bin2\",\"bin1\"],\"x\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"points\":\"all\",\"jitter\":0.1,\"orientation\":\"h\",\"meanline\":{\"visible\":true},\"marker\":{}}];" + """var data = [{"type":"violin","x":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"y":["bin1","bin2","bin1","bin2","bin1","bin2","bin1","bin1","bin2","bin1"],"orientation":"h","box":{},"jitter":0.1,"meanline":{"visible":true},"points":"all","marker":{}}];""" |> chartGeneratedContains violin2Chart ); testCase "Violin2 layout" ( fun () -> emptyLayout violin2Chart ); testCase "Violin3 data" ( fun () -> - "var data = [{\"type\":\"violin\",\"y\":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":\"y\",\"points\":\"all\",\"jitter\":0.1,\"name\":\"bin1\",\"marker\":{}},{\"type\":\"violin\",\"y\":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],\"x\":\"y'\",\"points\":\"all\",\"jitter\":0.1,\"name\":\"bin2\",\"marker\":{}}];" + """var data = [{"type":"violin","name":"bin1","x":"y","y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"box":{},"jitter":0.1,"points":"all","marker":{}},{"type":"violin","name":"bin2","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"box":{},"jitter":0.1,"points":"all","marker":{}}];""" |> chartGeneratedContains violin3Chart ); testCase "Violin3 layout" ( fun () -> From 9d915cbfc9797f79c6908710f042f86d009c686d Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 13 Oct 2021 10:08:08 +0200 Subject: [PATCH 05/11] fix box/violin docs --- docs/04_1_box-plots.fsx | 8 ++++---- docs/04_2_violin-plots.fsx | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/04_1_box-plots.fsx b/docs/04_1_box-plots.fsx index 6a4150d84..fba03e338 100644 --- a/docs/04_1_box-plots.fsx +++ b/docs/04_1_box-plots.fsx @@ -45,7 +45,7 @@ Outliers may be plotted as individual points. *) let box1 = - Chart.BoxPlot(x,y,Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All) + Chart.BoxPlot(x,y,Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All) (*** condition: ipynb ***) #if IPYNB @@ -60,7 +60,7 @@ box1 |> GenericChart.toChartHTML By swapping x and y plus using `StyleParam.Orientation.Horizontal` we can flip the chart horizontaly. *) let box2 = - Chart.BoxPlot(y,x,Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All,Orientation=StyleParam.Orientation.Horizontal) + Chart.BoxPlot(y,x,Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All,Orientation=StyleParam.Orientation.Horizontal) (*** condition: ipynb ***) #if IPYNB @@ -79,8 +79,8 @@ 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. let box3 = [ - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine diff --git a/docs/04_2_violin-plots.fsx b/docs/04_2_violin-plots.fsx index 72499f7e9..8f7d15cc8 100644 --- a/docs/04_2_violin-plots.fsx +++ b/docs/04_2_violin-plots.fsx @@ -47,7 +47,7 @@ data at different values. let violin1 = Chart.Violin ( x,y, - Points=StyleParam.Jitterpoints.All + Points=StyleParam.JitterPoints.All ) (*** condition: ipynb ***) @@ -68,9 +68,9 @@ let violin2 = Chart.Violin( y,x, Jitter=0.1, - Points=StyleParam.Jitterpoints.All, + Points=StyleParam.JitterPoints.All, Orientation=StyleParam.Orientation.Horizontal, - Meanline=Meanline.init(Visible=true) + MeanLine=MeanLine.init(Visible=true) ) (*** condition: ipynb ***) @@ -90,8 +90,8 @@ 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. let violin3 = [ - Chart.Violin ("y" ,y,Name="bin1",Jitter=0.1,Points=StyleParam.Jitterpoints.All); - Chart.Violin ("y'",y',Name="bin2",Jitter=0.1,Points=StyleParam.Jitterpoints.All); + Chart.Violin ("y" ,y,Name="bin1",Jitter=0.1,Points=StyleParam.JitterPoints.All); + Chart.Violin ("y'",y',Name="bin2",Jitter=0.1,Points=StyleParam.JitterPoints.All); ] |> Chart.combine From e304bc75cbb90e8a1cad0ba924c34f2fb08392b8 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 13 Oct 2021 16:28:38 +0200 Subject: [PATCH 06/11] Rename Meanline.fs to MeanLine.fs --- .../Traces/ObjectAbstractions/{Meanline.fs => MeanLine.fs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/Plotly.NET/Traces/ObjectAbstractions/{Meanline.fs => MeanLine.fs} (98%) diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs b/src/Plotly.NET/Traces/ObjectAbstractions/MeanLine.fs similarity index 98% rename from src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs rename to src/Plotly.NET/Traces/ObjectAbstractions/MeanLine.fs index fe9ce7412..19901783b 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Meanline.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/MeanLine.fs @@ -44,4 +44,4 @@ type MeanLine () = - \ No newline at end of file + From 10ded4e8b5bffebdcab2aef496ecb3d5a38346d0 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Thu, 14 Oct 2021 09:10:22 +0200 Subject: [PATCH 07/11] Add all params for Histogram traces, improve Chart functions --- src/Plotly.NET/ChartAPI/Chart2D.fs | 141 ++++++++++++++---- src/Plotly.NET/Playground.fsx | 26 +++- .../Traces/ObjectAbstractions/Bins.fs | 20 +-- src/Plotly.NET/Traces/Trace2D.fs | 137 +++++++++++------ 4 files changed, 239 insertions(+), 85 deletions(-) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index da53e7be2..61b482c93 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1395,43 +1395,128 @@ module Chart2D = ?Marker = Marker ) - /// Computes a histogram with auto-determined the bin size. + + /// Visualizes the distribution of the input data as a histogram. [] static member Histogram - ( - data, - [] ?Orientation, - [] ?Name, - [] ?ShowLegend, - [] ?Opacity, - [] ?Color, - [] ?HistNorm, - [] ?HistFunc, - [] ?nBinsx, - [] ?nBinsy, - [] ?Xbins, - [] ?Ybins, - // TODO - [] ?xError, - [] ?yError + ( + [] ?X : seq<#IConvertible>, + [] ?Y : seq<#IConvertible>, + [] ?Orientation : StyleParam.Orientation, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Opacity : float, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?AlignmentGroup : string, + [] ?OffsetGroup : string, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?BinGroup : string, + [] ?XBins : Bins, + [] ?YBins : Bins, + [] ?MarkerColor : Color, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?ErrorX : Error, + [] ?ErrorY : Error, + [] ?Cumulative : Cumulative, + [] ?HoverLabel : Hoverlabel ) = - Trace2D.initHistogram ( Trace2DStyle.Histogram ( - X=data, - ?Orientation=Orientation, - ?HistNorm=HistNorm, - ?HistFunc=HistFunc, - ?nBinsx=nBinsx, - ?nBinsy=nBinsy, - ?xBins=Xbins, - ?yBins=Ybins + ?X = X, + ?Y = Y, + ?Text = Text , + ?MultiText = MultiText , + ?Orientation = Orientation , + ?HistFunc = HistFunc , + ?HistNorm = HistNorm , + ?AlignmentGroup = AlignmentGroup , + ?OffsetGroup = OffsetGroup , + ?NBinsX = NBinsX , + ?NBinsY = NBinsY , + ?BinGroup = BinGroup , + ?XBins = XBins , + ?YBins = YBins , + ?Marker = Marker , + ?Line = Line , + ?ErrorX = ErrorX , + ?ErrorY = ErrorY , + ?Cumulative = Cumulative , + ?HoverLabel = HoverLabel ) ) - |> TraceStyle.Marker(?Color=Color) + |> TraceStyle.Marker(?Color=MarkerColor) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> GenericChart.ofTraceObject + + /// Visualizes the distribution of the input data as a histogram, automatically determining if the data is to be used for the x or y dimension based on the `orientation` parameter. + [] + static member Histogram + ( + data: seq<#IConvertible>, + orientation : StyleParam.Orientation, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Opacity : float, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?AlignmentGroup : string, + [] ?OffsetGroup : string, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?BinGroup : string, + [] ?XBins : Bins, + [] ?YBins : Bins, + [] ?MarkerColor : Color, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?ErrorX : Error, + [] ?ErrorY : Error, + [] ?Cumulative : Cumulative, + [] ?HoverLabel : Hoverlabel + ) = + + let histChart = + Trace2D.initHistogram ( + Trace2DStyle.Histogram ( + ?Text = Text , + ?MultiText = MultiText , + Orientation = orientation , + ?HistFunc = HistFunc , + ?HistNorm = HistNorm , + ?AlignmentGroup = AlignmentGroup , + ?OffsetGroup = OffsetGroup , + ?NBinsX = NBinsX , + ?NBinsY = NBinsY , + ?BinGroup = BinGroup , + ?XBins = XBins , + ?YBins = YBins , + ?Marker = Marker , + ?Line = Line , + ?ErrorX = ErrorX , + ?ErrorY = ErrorY , + ?Cumulative = Cumulative , + ?HoverLabel = HoverLabel + ) + ) + |> TraceStyle.Marker(?Color=MarkerColor) + |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) + |> GenericChart.ofTraceObject + + match orientation with + | StyleParam.Orientation.Horizontal -> + histChart + |> GenericChart.mapTrace (Trace2DStyle.Histogram(Y=data)) + | StyleParam.Orientation.Vertical -> + histChart + |> GenericChart.mapTrace (Trace2DStyle.Histogram(X=data)) + /// Computes the bi-dimensional histogram of two data samples and auto-determines the bin size. [] diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index b8128b5ff..404242758 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -160,7 +160,31 @@ open FSharpAux open System open System.IO - +[ + Chart.Histogram( + [for i in 0 .. 10000 do yield System.Random().NextDouble() * 10.], + StyleParam.Orientation.Vertical, + HistFunc = StyleParam.HistFunc.Avg, + HistNorm = StyleParam.HistNorm.ProbabilityDensity, + BinGroup = "myHist", + Opacity = 0.6 + ) + Chart.Histogram( + [for i in 0 .. 1000 do yield System.Random().NextDouble() * 10.], + StyleParam.Orientation.Vertical, + HistFunc = StyleParam.HistFunc.Avg, + HistNorm = StyleParam.HistNorm.ProbabilityDensity, + BinGroup = "myHist", + Opacity = 0.6 + ) +] +|> Chart.combine +|> Chart.withLayout( + Layout.init( + BarMode = StyleParam.BarMode.Overlay + ) +) +|> Chart.show let violin1Chart = let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Bins.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Bins.fs index 2a195e4fa..0960967c7 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Bins.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Bins.fs @@ -13,31 +13,31 @@ type Bins () = // Init Bins() static member init ( - [] ?StartBins: float, - [] ?EndBins: float, + [] ?Start: float, + [] ?End: float, [] ?Size: float ) = Bins () |> Bins.style ( - ?StartBins = StartBins, - ?EndBins = EndBins , - ?Size = Size + ?Start = Start, + ?End = End , + ?Size = Size ) // Applies the styles to Bins() static member style ( - [] ?StartBins: float, - [] ?EndBins: float, + [] ?Start: float, + [] ?End: float, [] ?Size: float ) = (fun (bins:Bins) -> - StartBins |> DynObj.setValueOpt bins "start" - EndBins |> DynObj.setValueOpt bins "end" - Size |> DynObj.setValueOpt bins "size" + Start |> DynObj.setValueOpt bins "start" + End |> DynObj.setValueOpt bins "end" + Size |> DynObj.setValueOpt bins "size" bins ) diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index 5878767d3..7cc10bc46 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -539,56 +539,101 @@ type Trace2DStyle() = // Applies the styles of histogram to TraceObjects static member Histogram ( - [] ?X : seq<#IConvertible> , - [] ?Y : seq<#IConvertible> , - [] ?Text : seq , - [] ?xAxis , - [] ?yAxis , - [] ?Xsrc , - [] ?Ysrc , - [] ?Orientation , - [] ?HistFunc , - [] ?HistNorm , - [] ?Cumulative : Cumulative , - [] ?Autobinx : bool , - [] ?nBinsx : int , - [] ?xBins : Bins , - [] ?Autobiny : bool , - [] ?nBinsy : int , - [] ?yBins : Bins , - [] ?Marker : Marker , - [] ?xError : Error , - [] ?yError : Error - + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?Y : seq<#IConvertible>, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HoverText : string, + [] ?MultiHoverText : seq, + [] ?HoverInfo : StyleParam.HoverInfo, + [] ?HoverTemplate : string, + [] ?MultiHoverTemplate: seq, + [] ?XHoverFormat : string, + [] ?YHoverFormat : string, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Orientation : StyleParam.Orientation, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?AlignmentGroup : string, + [] ?OffsetGroup : string, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?AutoBinX : bool, + [] ?AutoBinY : bool, + [] ?BinGroup : string, + [] ?XBins : Bins, + [] ?YBins : Bins, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?ErrorX : Error, + [] ?ErrorY : Error, + [] ?SelectedPoints : seq<#IConvertible>, + [] ?Selected : Selection, + [] ?Unselected : Selection, + [] ?Cumulative : Cumulative, + [] ?HoverLabel : Hoverlabel, + [] ?XCalendar : StyleParam.Calendar, + [] ?YCalendar : StyleParam.Calendar, + [] ?UIRevision : string ) = (fun (histogram:('T :> Trace)) -> - X |> DynObj.setValueOpt histogram "x" - Y |> DynObj.setValueOpt histogram "y" - Text |> DynObj.setValueOpt histogram "text" - xAxis |> DynObj.setValueOpt histogram "xaxis" - yAxis |> DynObj.setValueOpt histogram "yaxis" - Xsrc |> DynObj.setValueOpt histogram "xsrc" - Ysrc |> DynObj.setValueOpt histogram "ysrc" - - Orientation |> DynObj.setValueOptBy histogram "orientation" StyleParam.Orientation.convert - HistFunc |> DynObj.setValueOptBy histogram "histfunc" StyleParam.HistFunc.convert - HistNorm |> DynObj.setValueOptBy histogram "histnorm" StyleParam.HistNorm.convert - Cumulative |> DynObj.setValueOpt histogram "cumulative" - - Autobinx |> DynObj.setValueOpt histogram "autobinx" - nBinsx |> DynObj.setValueOpt histogram "nbinsx" - xBins |> DynObj.setValueOpt histogram "xbins" - Autobiny |> DynObj.setValueOpt histogram "autobiny" - nBinsy |> DynObj.setValueOpt histogram "nbinsy" - yBins |> DynObj.setValueOpt histogram "ybins" + Name |> DynObj.setValueOpt histogram "name" + Visible |> DynObj.setValueOptBy histogram "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt histogram "showlegend" + LegendRank |> DynObj.setValueOpt histogram "legendrank" + LegendGroup |> DynObj.setValueOpt histogram "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt histogram "legendgrouptitle" + Opacity |> DynObj.setValueOpt histogram "opacity" + Ids |> DynObj.setValueOpt histogram "ids" + X |> DynObj.setValueOpt histogram "x" + Y |> DynObj.setValueOpt histogram "y" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt histogram "text" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt histogram "hovertext" + HoverInfo |> DynObj.setValueOptBy histogram "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt histogram "hovertemplate" + XHoverFormat |> DynObj.setValueOpt histogram "xhoverformat" + YHoverFormat |> DynObj.setValueOpt histogram "yhoverformat" + Meta |> DynObj.setValueOpt histogram "meta" + CustomData |> DynObj.setValueOpt histogram "customdata" + XAxis |> DynObj.setValueOptBy histogram "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy histogram "yaxis" StyleParam.LinearAxisId.convert + Orientation |> DynObj.setValueOptBy histogram "orientation" StyleParam.Orientation.convert + HistFunc |> DynObj.setValueOptBy histogram "histfunc" StyleParam.HistFunc.convert + HistNorm |> DynObj.setValueOptBy histogram "histnorm" StyleParam.HistNorm.convert + AlignmentGroup |> DynObj.setValueOpt histogram "alignmentgroup" + OffsetGroup |> DynObj.setValueOpt histogram "offsetgroup" + NBinsX |> DynObj.setValueOpt histogram "nbinsx" + NBinsY |> DynObj.setValueOpt histogram "nbinsy" + AutoBinX |> DynObj.setValueOpt histogram "autobinx" + AutoBinY |> DynObj.setValueOpt histogram "autobiny" + BinGroup |> DynObj.setValueOpt histogram "bingroup" + XBins |> DynObj.setValueOpt histogram "xbins" + YBins |> DynObj.setValueOpt histogram "ybins" + Marker |> DynObj.setValueOpt histogram "marker" + Line |> DynObj.setValueOpt histogram "line" + ErrorX |> DynObj.setValueOpt histogram "error_x" + ErrorY |> DynObj.setValueOpt histogram "error_y" + SelectedPoints |> DynObj.setValueOpt histogram "selectedpoints" + Selected |> DynObj.setValueOpt histogram "selected" + Unselected |> DynObj.setValueOpt histogram "unselected" + Cumulative |> DynObj.setValueOpt histogram "cumulative" + HoverLabel |> DynObj.setValueOpt histogram "hoverlabel" + XCalendar |> DynObj.setValueOptBy histogram "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy histogram "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt histogram "uirevision" - // Update - Marker |> DynObj.setValueOpt histogram "marker" - xError |> DynObj.setValueOpt histogram "error_x" - yError |> DynObj.setValueOpt histogram "error_y" - - // out -> histogram ) From ba30a215e5d7d39932ef94a1884d6532e48fcf47 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Thu, 14 Oct 2021 09:18:12 +0200 Subject: [PATCH 08/11] fix multichart docs --- docs/01_2_multiple-charts.fsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/01_2_multiple-charts.fsx b/docs/01_2_multiple-charts.fsx index 960c393a4..0a446c116 100644 --- a/docs/01_2_multiple-charts.fsx +++ b/docs/01_2_multiple-charts.fsx @@ -260,8 +260,8 @@ let multipleTraceTypesGrid = [ // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) 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.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine ] From a2e59a4498cc2275ff97d695c9b69276c7c8e9de Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Sat, 16 Oct 2021 09:39:10 +0200 Subject: [PATCH 09/11] Add all missing params for histogram2d --- src/Plotly.NET/ChartAPI/Chart2D.fs | 76 +++++++------ src/Plotly.NET/Playground.fsx | 3 + src/Plotly.NET/Traces/Trace2D.fs | 174 ++++++++++++++++------------- 3 files changed, 137 insertions(+), 116 deletions(-) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 61b482c93..2b43cd5a6 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1517,48 +1517,52 @@ module Chart2D = histChart |> GenericChart.mapTrace (Trace2DStyle.Histogram(X=data)) - - /// Computes the bi-dimensional histogram of two data samples and auto-determines the bin size. + /// Computes the bi-dimensional histogram of two data samples. [] static member Histogram2d ( - x,y, - [] ?Z, - [] ?Name, - [] ?ShowLegend, - [] ?Opacity, - [] ?Colorscale, - [] ?Showscale, - [] ?zSmooth, - [] ?ColorBar, - [] ?zAuto, - [] ?zMin, - [] ?zMax, - [] ?nBinsx, - [] ?nBinsy, - [] ?xBins, - [] ?yBins, - [] ?HistNorm, - [] ?HistFunc + x : seq<#IConvertible>, + y : seq<#IConvertible>, + [] ?Z : seq<#seq<#IConvertible>>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Opacity : float, + [] ?XGap : int, + [] ?YGap : int, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?AutoBinX : bool, + [] ?AutoBinY : bool, + [] ?XBins : Bins, + [] ?YBins : Bins, + [] ?ColorBar : ColorBar, + [] ?ColorScale : StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?ReverseScale : bool, + [] ?ZSmooth : StyleParam.SmoothAlg ) = Trace2D.initHistogram2d ( Trace2DStyle.Histogram2d ( - X=x, - Y=y, - ?Z=Z, - ?Colorscale=Colorscale, - ?Showscale=Showscale, - ?zSmooth=zSmooth, - ?ColorBar=ColorBar, - ?zAuto=zAuto, - ?zMin=zMin, - ?zMax=zMax, - ?nBinsx=nBinsx, - ?nBinsy=nBinsy, - ?xBins=xBins, - ?yBins=yBins, - ?HistNorm=HistNorm, - ?HistFunc=HistFunc + X = x , + ?XGap = XGap , + Y = y , + ?YGap = YGap , + ?Z = Z , + ?HistFunc = HistFunc , + ?HistNorm = HistNorm , + ?NBinsX = NBinsX , + ?NBinsY = NBinsY , + ?AutoBinX = AutoBinX , + ?AutoBinY = AutoBinY , + ?XBins = XBins , + ?YBins = YBins , + ?ColorBar = ColorBar , + ?ColorScale = ColorScale , + ?ShowScale = ShowScale , + ?ReverseScale = ReverseScale, + ?ZSmooth = ZSmooth ) ) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index 404242758..f7989eb12 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -160,6 +160,9 @@ open FSharpAux open System open System.IO + + + [ Chart.Histogram( [for i in 0 .. 10000 do yield System.Random().NextDouble() * 10.], diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index 7cc10bc46..2cd0f491b 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -888,89 +888,103 @@ type Trace2DStyle() = static member Histogram2d ( - [] ?X : seq<#IConvertible> , - [] ?Y : seq<#IConvertible> , - [] ?Z : seq<#seq<#IConvertible>> , - [] ?X0 , - [] ?dX , - [] ?Y0 , - [] ?dY , - [] ?xType , - [] ?yType , - [] ?xAxis , - [] ?yAxis , - [] ?Zsrc , - [] ?Xsrc , - [] ?Ysrc , - [] ?Marker : Marker , - [] ?Orientation , - [] ?HistFunc , - [] ?HistNorm , - [] ?Autobinx : bool , - [] ?nBinsx : int , - [] ?xBins : Bins , - [] ?Autobiny : bool , - [] ?nBinsy : int , - [] ?yBins : Bins , - [] ?Xgap , - [] ?Ygap , - [] ?Transpose , - [] ?zAuto , - [] ?zMin , - [] ?zMax , - [] ?Colorscale , - [] ?Autocolorscale , - [] ?Reversescale , - [] ?Showscale , - [] ?zSmooth , - [] ?ColorBar - + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?XGap : int, + [] ?Y : seq<#IConvertible>, + [] ?YGap : int, + [] ?Z : seq<#seq<#IConvertible>>, + [] ?HoverInfo : StyleParam.HoverInfo, + [] ?HoverTemplate : string, + [] ?MultiHoverTemplate: seq, + [] ?XHoverFormat : string, + [] ?YHoverFormat : string, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?AutoBinX : bool, + [] ?AutoBinY : bool, + [] ?XBins : Bins, + [] ?YBins : Bins, + [] ?Marker : Marker, + [] ?ColorBar : ColorBar, + [] ?AutoColorScale : bool, + [] ?ColorScale : StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?ReverseScale : bool, + [] ?ZAuto : bool, + [] ?ZHoverFormat : string, + [] ?Zmin : float, + [] ?Zmid : float, + [] ?Zmax : float, + [] ?ZSmooth : StyleParam.SmoothAlg, + [] ?HoverLabel : Hoverlabel, + [] ?XCalendar : StyleParam.Calendar, + [] ?YCalendar : StyleParam.Calendar, + [] ?UIRevision : string ) = (fun (histogram2d:('T :> Trace)) -> - Z |> DynObj.setValueOpt histogram2d "z" - X |> DynObj.setValueOpt histogram2d "x" - Y |> DynObj.setValueOpt histogram2d "y" - X0 |> DynObj.setValueOpt histogram2d "x0" - dX |> DynObj.setValueOpt histogram2d "dx" - Y0 |> DynObj.setValueOpt histogram2d "y0" - dY |> DynObj.setValueOpt histogram2d "dy" - xType |> DynObj.setValueOpt histogram2d "xtype" - yType |> DynObj.setValueOpt histogram2d "ytype" - xAxis |> DynObj.setValueOpt histogram2d "xaxis" - yAxis |> DynObj.setValueOpt histogram2d "yaxis" - Zsrc |> DynObj.setValueOpt histogram2d "zsrc" - Xsrc |> DynObj.setValueOpt histogram2d "xsrc" - Ysrc |> DynObj.setValueOpt histogram2d "ysrc" - - Orientation |> DynObj.setValueOptBy histogram2d "orientation" StyleParam.Orientation.convert - //Connectgaps |> DynObj.setValueOptBy histogram2d "connectgaps" StyleParam.Orientation.convert - HistFunc |> DynObj.setValueOptBy histogram2d "histfunc " StyleParam.HistFunc.convert - HistNorm |> DynObj.setValueOptBy histogram2d "histnorm " StyleParam.HistNorm.convert - Autobinx |> DynObj.setValueOpt histogram2d "autobinx" - nBinsx |> DynObj.setValueOpt histogram2d "nbinsx" - xBins |> DynObj.setValueOpt histogram2d "xbins" - Autobiny |> DynObj.setValueOpt histogram2d "autobiny" - nBinsy |> DynObj.setValueOpt histogram2d "nbinsy" - yBins |> DynObj.setValueOpt histogram2d "ybins" - - Xgap |> DynObj.setValueOpt histogram2d "xgap" - Ygap |> DynObj.setValueOpt histogram2d "ygap" - Transpose |> DynObj.setValueOpt histogram2d "transpose" - zAuto |> DynObj.setValueOpt histogram2d "zauto" - zMin |> DynObj.setValueOpt histogram2d "zmin" - zMax |> DynObj.setValueOpt histogram2d "zmax" - Colorscale |> DynObj.setValueOptBy histogram2d "colorscale" StyleParam.Colorscale.convert - Autocolorscale |> DynObj.setValueOpt histogram2d "autocolorscale" - Reversescale |> DynObj.setValueOpt histogram2d "reversescale" - Showscale |> DynObj.setValueOpt histogram2d "showscale" - zSmooth |> DynObj.setValueOptBy histogram2d "zsmooth" StyleParam.SmoothAlg.convert - ColorBar |> DynObj.setValueOpt histogram2d "colorbar" - - // Update - Marker |> DynObj.setValueOpt histogram2d "marker" - - // out -> + Name |> DynObj.setValueOpt histogram2d "name" + Visible |> DynObj.setValueOptBy histogram2d "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt histogram2d "showlegend" + LegendRank |> DynObj.setValueOpt histogram2d "legendrank" + LegendGroup |> DynObj.setValueOpt histogram2d "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt histogram2d "legendgrouptitle" + Opacity |> DynObj.setValueOpt histogram2d "opacity" + Ids |> DynObj.setValueOpt histogram2d "ids" + X |> DynObj.setValueOpt histogram2d "x" + XGap |> DynObj.setValueOpt histogram2d "xgap" + Y |> DynObj.setValueOpt histogram2d "y" + YGap |> DynObj.setValueOpt histogram2d "ygap" + Z |> DynObj.setValueOpt histogram2d "z" + HoverInfo |> DynObj.setValueOptBy histogram2d "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt histogram2d "hovertemplate" + XHoverFormat |> DynObj.setValueOpt histogram2d "xhoverformat" + YHoverFormat |> DynObj.setValueOpt histogram2d "yhoverformat" + Meta |> DynObj.setValueOpt histogram2d "meta" + CustomData |> DynObj.setValueOpt histogram2d "customdata" + XAxis |> DynObj.setValueOptBy histogram2d "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy histogram2d "yaxis" StyleParam.LinearAxisId.convert + ColorAxis |> DynObj.setValueOpt histogram2d "coloraxis" + HistFunc |> DynObj.setValueOptBy histogram2d "histfunc" StyleParam.HistFunc.convert + HistNorm |> DynObj.setValueOptBy histogram2d "histnorm" StyleParam.HistNorm.convert + NBinsX |> DynObj.setValueOpt histogram2d "nbinsx" + NBinsY |> DynObj.setValueOpt histogram2d "nbinsy" + AutoBinX |> DynObj.setValueOpt histogram2d "autobinx" + AutoBinY |> DynObj.setValueOpt histogram2d "autobiny" + XBins |> DynObj.setValueOpt histogram2d "xbins" + YBins |> DynObj.setValueOpt histogram2d "ybins" + Marker |> DynObj.setValueOpt histogram2d "marker" + ColorBar |> DynObj.setValueOpt histogram2d "colorbar" + AutoColorScale |> DynObj.setValueOpt histogram2d "autocolorscale" + ColorScale |> DynObj.setValueOptBy histogram2d "colorscale" StyleParam.Colorscale.convert + ShowScale |> DynObj.setValueOpt histogram2d "showscale" + ReverseScale |> DynObj.setValueOpt histogram2d "reversescale" + ZAuto |> DynObj.setValueOpt histogram2d "zauto" + ZHoverFormat |> DynObj.setValueOpt histogram2d "zhoverformat" + Zmin |> DynObj.setValueOpt histogram2d "zmin" + Zmid |> DynObj.setValueOpt histogram2d "zmid" + Zmax |> DynObj.setValueOpt histogram2d "zmax" + ZSmooth |> DynObj.setValueOptBy histogram2d "zsmooth" StyleParam.SmoothAlg.convert + HoverLabel |> DynObj.setValueOpt histogram2d "hoverlabel" + XCalendar |> DynObj.setValueOptBy histogram2d "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy histogram2d "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt histogram2d "uirevision" + histogram2d ) From 9a34c855b48f8c21aed0ab1a5324865d7a718b70 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Sat, 16 Oct 2021 09:52:30 +0200 Subject: [PATCH 10/11] fix #154 --- src/Plotly.NET/CommonAbstractions/StyleParams.fs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index f3a8085d0..01e2ba1db 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -247,14 +247,12 @@ module StyleParam = | True | False | SD - - static member toString = function - | True -> "true" - | False -> "false" - | SD -> "SD" - static member convert = BoxMean.toString >> box - override this.ToString() = this |> BoxMean.toString + static member convert = function + | True -> box true + | False -> box false + | SD -> box "sd" + member this.Convert() = this |> BoxMean.convert /// For bar and histogram plots only. This sets how multiple bar objects are plotted together. In other words, this defines how bars at the same location From a7e7473ab12c9ac1c243595eaad738c28efdaf69 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Sat, 16 Oct 2021 11:00:00 +0200 Subject: [PATCH 11/11] Add al histogram2Dcontour params, rename 2d -> 2D --- docs/00_1_image-export.fsx | 2 +- docs/04_4_2d-histograms.fsx | 12 +- src/Plotly.NET/ChartAPI/Chart.fs | 14 +- src/Plotly.NET/ChartAPI/Chart2D.fs | 91 ++--- src/Plotly.NET/Playground.fsx | 31 +- src/Plotly.NET/Traces/Trace2D.fs | 313 ++++++++++-------- .../HtmlCodegen/DistributionCharts.fs | 18 +- 7 files changed, 268 insertions(+), 213 deletions(-) diff --git a/docs/00_1_image-export.fsx b/docs/00_1_image-export.fsx index a17671483..7cc844c9f 100644 --- a/docs/00_1_image-export.fsx +++ b/docs/00_1_image-export.fsx @@ -65,7 +65,7 @@ open Plotly.NET open Plotly.NET.ImageExport let exampleChart = - Chart.Histogram2dContour( + Chart.Histogram2DContour( [1.;2.;2.;4.;5.], [1.;2.;2.;4.;5.] ) diff --git a/docs/04_4_2d-histograms.fsx b/docs/04_4_2d-histograms.fsx index 65a6aeede..afd35ad6d 100644 --- a/docs/04_4_2d-histograms.fsx +++ b/docs/04_4_2d-histograms.fsx @@ -57,12 +57,12 @@ let x = Array.init n (fun i -> ((step i)**3.) + (0.3 * (normal (rnd) 0. 2.) )) let y = Array.init n (fun i -> ((step i)**6.) + (0.3 * (normal (rnd) 0. 2.) )) (** -A Histogram2d chart can be created using the `Chart.Histogram2d` or `Chart.Histogram2dContour` functions. +A Histogram2D chart can be created using the `Chart.Histogram2D` or `Chart.Histogram2DContour` functions. *) let histogramContour = [ - Chart.Histogram2dContour (x,y,Line=Line.init(Width=0.)) + Chart.Histogram2DContour (x,y,Line=Line.init(Width=0.)) Chart.Point(x,y,Opacity=0.3) ] |> Chart.combine @@ -76,14 +76,14 @@ histogramContour histogramContour |> GenericChart.toChartHTML (*** include-it-raw ***) -let histogram2d = - Chart.Histogram2d (x,y) +let histogram2D = + Chart.Histogram2D (x,y) (*** condition: ipynb ***) #if IPYNB -histogram2d +histogram2D #endif // IPYNB (***hide***) -histogram2d |> GenericChart.toChartHTML +histogram2D |> GenericChart.toChartHTML (*** include-it-raw ***) \ No newline at end of file diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index a34584509..0db04df8e 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -296,7 +296,7 @@ type Chart = static member withX_Axis(xAxis:LinearAxis,[] ?Id : StyleParam.SubPlotId) = Chart.withXAxis(xAxis, ?Id = Id) - // Sets x-Axis of 2d and 3d- Charts + // Sets x-Axis of 2D and 3d- Charts [] static member withXAxis(xAxis:LinearAxis,[] ?Id: StyleParam.SubPlotId) = fun (ch:GenericChart) -> @@ -358,7 +358,7 @@ type Chart = ?Anchor = Anchor) - // Sets x-Axis of 2d and 3d- Charts + // Sets x-Axis of 2D and 3d- Charts [] static member withXAxisStyle(title, [] ?TitleFont, @@ -396,7 +396,7 @@ type Chart = static member withY_Axis(yAxis:LinearAxis,[] ?Id: StyleParam.SubPlotId) = Chart.withYAxis(yAxis, ?Id = Id) - // Sets y-Axis of 2d and 3d- Charts + // Sets y-Axis of 2D and 3d- Charts [] static member withYAxis(yAxis:LinearAxis,[] ?Id: StyleParam.SubPlotId) = fun (ch:GenericChart) -> @@ -559,7 +559,7 @@ type Chart = [] ?BGColor) = let colorbar = ColorBar.init(Title=title,?Len = Length,?OutlineColor=OutlineColor,?BGColor=BGColor,?BorderColor=BorderColor) Chart.withColorBar(colorbar) - //// Sets second x-Axis of 2d- Charts + //// Sets second x-Axis of 2D- Charts //static member withX_Axis2(xAxis2:Axis.LinearAxis) = // (fun (ch:GenericChart) -> // let layout = @@ -569,14 +569,14 @@ type Chart = // ) - // // Sets second x-Axis of 2d- Charts + // // Sets second x-Axis of 2D- Charts //static member withX_Axis2Style(title,?MinMax,?Showgrid,?Showline) = // let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None // let xaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Top) // Chart.withX_Axis2(xaxis) - //// Sets second y-Axis of 2d- Charts + //// Sets second y-Axis of 2D- Charts //static member withY_Axis2(yAxis2:Axis.LinearAxis) = // (fun (ch:GenericChart) -> // let layout = @@ -586,7 +586,7 @@ type Chart = // ) - // // Sets second x-Axis of 2d- Charts + // // Sets second x-Axis of 2D- Charts //static member withY_Axis2Style(title,?MinMax,?Showgrid,?Showline) = // let range = if MinMax.IsSome then Some (StyleParam.Range.MinMax (MinMax.Value)) else None // let yaxis = Axis.LinearAxis.init(Title=title,?Range=range,?Showgrid=Showgrid,?Showline=Showline,Side=StyleParam.Side.Right) diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 2b43cd5a6..5445e796f 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -1519,7 +1519,7 @@ module Chart2D = /// Computes the bi-dimensional histogram of two data samples. [] - static member Histogram2d + static member Histogram2D ( x : seq<#IConvertible>, y : seq<#IConvertible>, @@ -1543,8 +1543,8 @@ module Chart2D = [] ?ReverseScale : bool, [] ?ZSmooth : StyleParam.SmoothAlg ) = - Trace2D.initHistogram2d ( - Trace2DStyle.Histogram2d ( + Trace2D.initHistogram2D ( + Trace2DStyle.Histogram2D ( X = x , ?XGap = XGap , Y = y , @@ -1826,43 +1826,60 @@ module Chart2D = /// Computes the bi-dimensional histogram of two data samples and auto-determines the bin size. [] - static member Histogram2dContour + static member Histogram2DContour ( - x,y, - [] ?Z, - [] ?Name, - [] ?Colorscale, - [] ?Showscale, - [] ?Line, - [] ?zSmooth, - [] ?ColorBar, - [] ?zAuto, - [] ?zMin, - [] ?zMax, - [] ?nBinsx, - [] ?nBinsy, - [] ?xBins, - [] ?yBins, - [] ?HistNorm, - [] ?HistFunc - ) = - Trace2D.initHistogram2dContour ( - Trace2DStyle.Histogram2dContour (X=x, Y=y,? Z=Z,?Line=Line, - ?Colorscale=Colorscale, - ?Showscale=Showscale, - ?zSmooth=zSmooth, - ?ColorBar=ColorBar, - ?zAuto=zAuto, - ?zMin=zMin, - ?zMax=zMax, - ?nBinsx=nBinsx, - ?nBinsy=nBinsy, - ?xBins=xBins, - ?yBins=yBins, - ?HistNorm=HistNorm, - ?HistFunc=HistFunc + x : seq<#IConvertible>, + y : seq<#IConvertible>, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Opacity : float, + [] ?Z : seq<#seq<#IConvertible>>, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?BinGroup : string, + [] ?XBinGroup : string, + [] ?XBins : Bins, + [] ?YBinGroup : string, + [] ?YBins : Bins, + [] ?Marker : Marker, + [] ?LineDash : StyleParam.DrawingStyle, + [] ?LineColor : Color, + [] ?Line : Line, + [] ?ColorBar : ColorBar, + [] ?ColorScale : StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?ReverseScale : bool, + [] ?Contours : Contours, + [] ?NContours : int + ) = + Trace2D.initHistogram2DContour ( + Trace2DStyle.Histogram2DContour ( + X = x, + Y = y, + ?Z = Z , + ?HistFunc = HistFunc , + ?HistNorm = HistNorm , + ?NBinsX = NBinsX , + ?NBinsY = NBinsY , + ?BinGroup = BinGroup , + ?XBinGroup = XBinGroup , + ?XBins = XBins , + ?YBinGroup = YBinGroup , + ?YBins = YBins , + ?Marker = Marker , + ?Line = Line , + ?ColorBar = ColorBar , + ?ColorScale = ColorScale , + ?ShowScale = ShowScale , + ?ReverseScale = ReverseScale, + ?Contours = Contours , + ?NContours = NContours ) ) + |> TraceStyle.TraceInfo(?Name=Name, ?ShowLegend=ShowLegend, ?Opacity=Opacity) + |> TraceStyle.Line(?Color=LineColor, ?Dash=LineDash) |> GenericChart.ofTraceObject /// Shows a graphical representation of a 3-dimensional surface by plotting constant z slices, called contours, on a 2-dimensional format. diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index f7989eb12..ba19fade5 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -161,7 +161,24 @@ open FSharpAux open System open System.IO +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] +[ + Chart.BoxPlot(y=y,BoxPoints=StyleParam.BoxPoints.All,Jitter=0.5,Notched=true,MarkerColor = Color.fromString "red",BoxMean=StyleParam.BoxMean.True,Name="Only Mean"); + Chart.BoxPlot(y=y,BoxPoints=StyleParam.BoxPoints.All,Jitter=0.5,Notched=true,MarkerColor = Color.fromString "blue",BoxMean=StyleParam.BoxMean.SD,Name="Mean & SD") +] +|> Chart.combine +|> Chart.show + +Chart.Histogram2DContour( + [for _ in 0 .. 10000 do yield System.Random().NextDouble()], + [for _ in 0 .. 10000 do yield System.Random().NextDouble()], + LineDash = StyleParam.DrawingStyle.DashDot, + NContours= 20, + LineColor= Color.fromKeyword White, + ColorScale = StyleParam.Colorscale.Viridis +) +|> Chart.show [ Chart.Histogram( @@ -170,7 +187,8 @@ open System.IO HistFunc = StyleParam.HistFunc.Avg, HistNorm = StyleParam.HistNorm.ProbabilityDensity, BinGroup = "myHist", - Opacity = 0.6 + Opacity = 0.6, + Cumulative = Cumulative.init(Enabled=true) ) Chart.Histogram( [for i in 0 .. 1000 do yield System.Random().NextDouble() * 10.], @@ -178,7 +196,8 @@ open System.IO HistFunc = StyleParam.HistFunc.Avg, HistNorm = StyleParam.HistNorm.ProbabilityDensity, BinGroup = "myHist", - Opacity = 0.6 + Opacity = 0.6, + Cumulative = Cumulative.init(Enabled=true,Direction = StyleParam.CumulativeDirection.Decreasing) ) ] |> Chart.combine @@ -664,8 +683,8 @@ Chart.Invisible() [ - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y',Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine @@ -705,8 +724,8 @@ let heatmap2= Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) [ 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.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,Boxpoints=StyleParam.Boxpoints.All); + Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine ] diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index 2cd0f491b..f96211278 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -19,7 +19,7 @@ open System.Runtime.InteropServices /// top of one another to create dual-axis or multiple-axis charts. 2-d cartesian subplots lend themselves very well to creating /// "small multiples" figures, also known as facet or trellis plots. /// -/// The following trace types are compatible with 2d-cartesian subplots via the xaxis and yaxis attributes: +/// The following trace types are compatible with 2D-cartesian subplots via the xaxis and yaxis attributes: /// /// - scatter-like trace types: scatter and scattergl can be used to draw scatter plots, line plots and curves, time-series plots, /// bubble charts, dot plots and filled areas and also support error bars @@ -30,7 +30,7 @@ open System.Runtime.InteropServices /// /// - box and violin: 1-dimensional distribution-like trace types /// -/// - histogram2d and histogram2dcontour: 2-dimensional distribution-like density trace types +/// - histogram2D and histogram2Dcontour: 2-dimensional distribution-like density trace types /// /// - image, heatmap and contour: matrix trace types /// @@ -75,13 +75,13 @@ type Trace2D(traceTypeName) = static member initViolin (applyStyle: Trace2D -> Trace2D) = Trace2D("violin") |> applyStyle - ///initializes a trace of type "histogram2d" applying the given trace styling function - static member initHistogram2d (applyStyle: Trace2D -> Trace2D) = - Trace2D("histogram2d") |> applyStyle + ///initializes a trace of type "histogram2D" applying the given trace styling function + static member initHistogram2D (applyStyle: Trace2D -> Trace2D) = + Trace2D("histogram2D") |> applyStyle - ///initializes a trace of type "histogram2dcontour" applying the given trace styling function - static member initHistogram2dContour (applyStyle: Trace2D -> Trace2D) = - Trace2D("histogram2dcontour") |> applyStyle + ///initializes a trace of type "histogram2Dcontour" applying the given trace styling function + static member initHistogram2DContour (applyStyle: Trace2D -> Trace2D) = + Trace2D("histogram2Dcontour") |> applyStyle ///initializes a trace of type "image" applying the given trace styling function static member initImage (applyStyle: Trace2D -> Trace2D) = @@ -886,7 +886,7 @@ type Trace2DStyle() = ) - static member Histogram2d + static member Histogram2D ( [] ?Name : string, [] ?Visible : StyleParam.Visible, @@ -936,150 +936,169 @@ type Trace2DStyle() = [] ?YCalendar : StyleParam.Calendar, [] ?UIRevision : string ) = - (fun (histogram2d:('T :> Trace)) -> - - Name |> DynObj.setValueOpt histogram2d "name" - Visible |> DynObj.setValueOptBy histogram2d "visible" StyleParam.Visible.convert - ShowLegend |> DynObj.setValueOpt histogram2d "showlegend" - LegendRank |> DynObj.setValueOpt histogram2d "legendrank" - LegendGroup |> DynObj.setValueOpt histogram2d "legendgroup" - LegendGroupTitle |> DynObj.setValueOpt histogram2d "legendgrouptitle" - Opacity |> DynObj.setValueOpt histogram2d "opacity" - Ids |> DynObj.setValueOpt histogram2d "ids" - X |> DynObj.setValueOpt histogram2d "x" - XGap |> DynObj.setValueOpt histogram2d "xgap" - Y |> DynObj.setValueOpt histogram2d "y" - YGap |> DynObj.setValueOpt histogram2d "ygap" - Z |> DynObj.setValueOpt histogram2d "z" - HoverInfo |> DynObj.setValueOptBy histogram2d "hoverinfo" StyleParam.HoverInfo.convert - (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt histogram2d "hovertemplate" - XHoverFormat |> DynObj.setValueOpt histogram2d "xhoverformat" - YHoverFormat |> DynObj.setValueOpt histogram2d "yhoverformat" - Meta |> DynObj.setValueOpt histogram2d "meta" - CustomData |> DynObj.setValueOpt histogram2d "customdata" - XAxis |> DynObj.setValueOptBy histogram2d "xaxis" StyleParam.LinearAxisId.convert - YAxis |> DynObj.setValueOptBy histogram2d "yaxis" StyleParam.LinearAxisId.convert - ColorAxis |> DynObj.setValueOpt histogram2d "coloraxis" - HistFunc |> DynObj.setValueOptBy histogram2d "histfunc" StyleParam.HistFunc.convert - HistNorm |> DynObj.setValueOptBy histogram2d "histnorm" StyleParam.HistNorm.convert - NBinsX |> DynObj.setValueOpt histogram2d "nbinsx" - NBinsY |> DynObj.setValueOpt histogram2d "nbinsy" - AutoBinX |> DynObj.setValueOpt histogram2d "autobinx" - AutoBinY |> DynObj.setValueOpt histogram2d "autobiny" - XBins |> DynObj.setValueOpt histogram2d "xbins" - YBins |> DynObj.setValueOpt histogram2d "ybins" - Marker |> DynObj.setValueOpt histogram2d "marker" - ColorBar |> DynObj.setValueOpt histogram2d "colorbar" - AutoColorScale |> DynObj.setValueOpt histogram2d "autocolorscale" - ColorScale |> DynObj.setValueOptBy histogram2d "colorscale" StyleParam.Colorscale.convert - ShowScale |> DynObj.setValueOpt histogram2d "showscale" - ReverseScale |> DynObj.setValueOpt histogram2d "reversescale" - ZAuto |> DynObj.setValueOpt histogram2d "zauto" - ZHoverFormat |> DynObj.setValueOpt histogram2d "zhoverformat" - Zmin |> DynObj.setValueOpt histogram2d "zmin" - Zmid |> DynObj.setValueOpt histogram2d "zmid" - Zmax |> DynObj.setValueOpt histogram2d "zmax" - ZSmooth |> DynObj.setValueOptBy histogram2d "zsmooth" StyleParam.SmoothAlg.convert - HoverLabel |> DynObj.setValueOpt histogram2d "hoverlabel" - XCalendar |> DynObj.setValueOptBy histogram2d "xcalendar" StyleParam.Calendar.convert - YCalendar |> DynObj.setValueOptBy histogram2d "ycalendar" StyleParam.Calendar.convert - UIRevision |> DynObj.setValueOpt histogram2d "uirevision" + (fun (histogram2D:('T :> Trace)) -> + + Name |> DynObj.setValueOpt histogram2D "name" + Visible |> DynObj.setValueOptBy histogram2D "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt histogram2D "showlegend" + LegendRank |> DynObj.setValueOpt histogram2D "legendrank" + LegendGroup |> DynObj.setValueOpt histogram2D "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt histogram2D "legendgrouptitle" + Opacity |> DynObj.setValueOpt histogram2D "opacity" + Ids |> DynObj.setValueOpt histogram2D "ids" + X |> DynObj.setValueOpt histogram2D "x" + XGap |> DynObj.setValueOpt histogram2D "xgap" + Y |> DynObj.setValueOpt histogram2D "y" + YGap |> DynObj.setValueOpt histogram2D "ygap" + Z |> DynObj.setValueOpt histogram2D "z" + HoverInfo |> DynObj.setValueOptBy histogram2D "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt histogram2D "hovertemplate" + XHoverFormat |> DynObj.setValueOpt histogram2D "xhoverformat" + YHoverFormat |> DynObj.setValueOpt histogram2D "yhoverformat" + Meta |> DynObj.setValueOpt histogram2D "meta" + CustomData |> DynObj.setValueOpt histogram2D "customdata" + XAxis |> DynObj.setValueOptBy histogram2D "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy histogram2D "yaxis" StyleParam.LinearAxisId.convert + ColorAxis |> DynObj.setValueOpt histogram2D "coloraxis" + HistFunc |> DynObj.setValueOptBy histogram2D "histfunc" StyleParam.HistFunc.convert + HistNorm |> DynObj.setValueOptBy histogram2D "histnorm" StyleParam.HistNorm.convert + NBinsX |> DynObj.setValueOpt histogram2D "nbinsx" + NBinsY |> DynObj.setValueOpt histogram2D "nbinsy" + AutoBinX |> DynObj.setValueOpt histogram2D "autobinx" + AutoBinY |> DynObj.setValueOpt histogram2D "autobiny" + XBins |> DynObj.setValueOpt histogram2D "xbins" + YBins |> DynObj.setValueOpt histogram2D "ybins" + Marker |> DynObj.setValueOpt histogram2D "marker" + ColorBar |> DynObj.setValueOpt histogram2D "colorbar" + AutoColorScale |> DynObj.setValueOpt histogram2D "autocolorscale" + ColorScale |> DynObj.setValueOptBy histogram2D "colorscale" StyleParam.Colorscale.convert + ShowScale |> DynObj.setValueOpt histogram2D "showscale" + ReverseScale |> DynObj.setValueOpt histogram2D "reversescale" + ZAuto |> DynObj.setValueOpt histogram2D "zauto" + ZHoverFormat |> DynObj.setValueOpt histogram2D "zhoverformat" + Zmin |> DynObj.setValueOpt histogram2D "zmin" + Zmid |> DynObj.setValueOpt histogram2D "zmid" + Zmax |> DynObj.setValueOpt histogram2D "zmax" + ZSmooth |> DynObj.setValueOptBy histogram2D "zsmooth" StyleParam.SmoothAlg.convert + HoverLabel |> DynObj.setValueOpt histogram2D "hoverlabel" + XCalendar |> DynObj.setValueOptBy histogram2D "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy histogram2D "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt histogram2D "uirevision" - histogram2d + histogram2D ) - static member Histogram2dContour + static member Histogram2DContour ( - [] ?X : seq<#IConvertible> , - [] ?Y : seq<#IConvertible> , - [] ?Z : seq<#seq<#IConvertible>> , - [] ?X0 , - [] ?dX , - [] ?Y0 , - [] ?dY , - [] ?xType , - [] ?yType , - [] ?xAxis , - [] ?yAxis , - [] ?Zsrc , - [] ?Xsrc , - [] ?Ysrc , - [] ?Marker : Marker , - [] ?Orientation , - [] ?HistFunc , - [] ?HistNorm , - [] ?Autobinx : bool , - [] ?nBinsx : int , - [] ?xBins : Bins , - [] ?Autobiny : bool , - [] ?nBinsy : int , - [] ?yBins : Bins , - [] ?nContours : int , - [] ?Contours : Contour , - [] ?Line : Line , - [] ?Xgap , - [] ?Ygap , - [] ?Transpose , - [] ?zAuto , - [] ?zMin , - [] ?zMax , - [] ?Colorscale , - [] ?Autocolorscale , - [] ?Reversescale , - [] ?Showscale , - [] ?zSmooth , - [] ?ColorBar + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?Y : seq<#IConvertible>, + [] ?Z : seq<#seq<#IConvertible>>, + [] ?HoverInfo : StyleParam.HoverInfo, + [] ?HoverTemplate : string, + [] ?MultiHoverTemplate: seq, + [] ?XHoverFormat : string, + [] ?YHoverFormat : string, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?HistFunc : StyleParam.HistFunc, + [] ?HistNorm : StyleParam.HistNorm, + [] ?NBinsX : int, + [] ?NBinsY : int, + [] ?AutoBinX : bool, + [] ?AutoBinY : bool, + [] ?BinGroup : string, + [] ?XBinGroup : string, + [] ?XBins : Bins, + [] ?YBinGroup : string, + [] ?YBins : Bins, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?ColorBar : ColorBar, + [] ?AutoColorScale : bool, + [] ?ColorScale : StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?ReverseScale : bool, + [] ?ZAuto : bool, + [] ?ZHoverFormat : string, + [] ?Zmin : float, + [] ?Zmid : float, + [] ?Zmax : float, + [] ?AutoContour : bool, + [] ?Contours : Contours, + [] ?HoverLabel : Hoverlabel, + [] ?NContours : int, + [] ?XCalendar : StyleParam.Calendar, + [] ?YCalendar : StyleParam.Calendar, + [] ?UIRevision : string + + ) = - (fun (histogram2dContour:('T :> Trace)) -> - - Z |> DynObj.setValueOpt histogram2dContour "z" - X |> DynObj.setValueOpt histogram2dContour "x" - Y |> DynObj.setValueOpt histogram2dContour "y" - X0 |> DynObj.setValueOpt histogram2dContour "x0" - dX |> DynObj.setValueOpt histogram2dContour "dx" - Y0 |> DynObj.setValueOpt histogram2dContour "y0" - dY |> DynObj.setValueOpt histogram2dContour "dy" - xType |> DynObj.setValueOpt histogram2dContour "xtype" - yType |> DynObj.setValueOpt histogram2dContour "ytype" - xAxis |> DynObj.setValueOpt histogram2dContour "xaxis" - yAxis |> DynObj.setValueOpt histogram2dContour "yaxis" - Zsrc |> DynObj.setValueOpt histogram2dContour "zsrc" - Xsrc |> DynObj.setValueOpt histogram2dContour "xsrc" - Ysrc |> DynObj.setValueOpt histogram2dContour "ysrc" - - Orientation |> DynObj.setValueOptBy histogram2dContour "orientation" StyleParam.Orientation.convert - //Connectgaps |> DynObj.setValueOptBy histogram2dContour< "connectgaps" StyleParam.Orientation.convert - HistFunc |> DynObj.setValueOptBy histogram2dContour "histfunc " StyleParam.HistFunc.convert - HistNorm |> DynObj.setValueOptBy histogram2dContour "histnorm " StyleParam.HistNorm.convert - Autobinx |> DynObj.setValueOpt histogram2dContour "autobinx" - nBinsx |> DynObj.setValueOpt histogram2dContour "nbinsx" - xBins |> DynObj.setValueOpt histogram2dContour "xbins" - Autobiny |> DynObj.setValueOpt histogram2dContour "autobiny" - nBinsy |> DynObj.setValueOpt histogram2dContour "nbinsy" - yBins |> DynObj.setValueOpt histogram2dContour "ybins" - - nContours |> DynObj.setValueOpt histogram2dContour "ncontours" - Contours |> DynObj.setValueOpt histogram2dContour "contours" - Line |> DynObj.setValueOpt histogram2dContour "line" - Xgap |> DynObj.setValueOpt histogram2dContour "xgap" - Ygap |> DynObj.setValueOpt histogram2dContour "ygap" - Transpose |> DynObj.setValueOpt histogram2dContour "transpose" - zAuto |> DynObj.setValueOpt histogram2dContour "zauto" - zMin |> DynObj.setValueOpt histogram2dContour "zmin" - zMax |> DynObj.setValueOpt histogram2dContour "zmax" - Colorscale |> DynObj.setValueOptBy histogram2dContour "colorscale" StyleParam.Colorscale.convert - Autocolorscale |> DynObj.setValueOpt histogram2dContour "autocolorscale" - Reversescale |> DynObj.setValueOpt histogram2dContour "reversescale" - Showscale |> DynObj.setValueOpt histogram2dContour "showscale" - zSmooth |> DynObj.setValueOptBy histogram2dContour "zsmooth" StyleParam.SmoothAlg.convert - ColorBar |> DynObj.setValueOpt histogram2dContour "colorbar" - - // Update - Marker |> DynObj.setValueOpt histogram2dContour "marker" - - // out -> - histogram2dContour + (fun (histogram2DContour:('T :> Trace)) -> + + Name |> DynObj.setValueOpt histogram2DContour "name" + Visible |> DynObj.setValueOptBy histogram2DContour "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt histogram2DContour "showlegend" + LegendRank |> DynObj.setValueOpt histogram2DContour "legendrank" + LegendGroup |> DynObj.setValueOpt histogram2DContour "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt histogram2DContour "legendgrouptitle" + Opacity |> DynObj.setValueOpt histogram2DContour "opacity" + Ids |> DynObj.setValueOpt histogram2DContour "ids" + X |> DynObj.setValueOpt histogram2DContour "x" + Y |> DynObj.setValueOpt histogram2DContour "y" + Z |> DynObj.setValueOpt histogram2DContour "z" + HoverInfo |> DynObj.setValueOptBy histogram2DContour "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt histogram2DContour "hovertemplate" + XHoverFormat |> DynObj.setValueOpt histogram2DContour "xhoverformat" + YHoverFormat |> DynObj.setValueOpt histogram2DContour "yhoverformat" + Meta |> DynObj.setValueOpt histogram2DContour "meta" + CustomData |> DynObj.setValueOpt histogram2DContour "customdata" + XAxis |> DynObj.setValueOptBy histogram2DContour "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy histogram2DContour "yaxis" StyleParam.LinearAxisId.convert + ColorAxis |> DynObj.setValueOpt histogram2DContour "coloraxis" + HistFunc |> DynObj.setValueOptBy histogram2DContour "histfunc" StyleParam.HistFunc.convert + HistNorm |> DynObj.setValueOptBy histogram2DContour "histnorm" StyleParam.HistNorm.convert + NBinsX |> DynObj.setValueOpt histogram2DContour "nbinsx" + NBinsY |> DynObj.setValueOpt histogram2DContour "nbinsy" + AutoBinX |> DynObj.setValueOpt histogram2DContour "autobinx" + AutoBinY |> DynObj.setValueOpt histogram2DContour "autobiny" + BinGroup |> DynObj.setValueOpt histogram2DContour "bingroup" + XBinGroup |> DynObj.setValueOpt histogram2DContour "xbingroup" + XBins |> DynObj.setValueOpt histogram2DContour "xbins" + YBinGroup |> DynObj.setValueOpt histogram2DContour "ybingroup" + YBins |> DynObj.setValueOpt histogram2DContour "ybins" + Marker |> DynObj.setValueOpt histogram2DContour "marker" + Line |> DynObj.setValueOpt histogram2DContour "line" + ColorBar |> DynObj.setValueOpt histogram2DContour "colorbar" + AutoColorScale |> DynObj.setValueOpt histogram2DContour "autocolorscale" + ColorScale |> DynObj.setValueOptBy histogram2DContour "colorscale" StyleParam.Colorscale.convert + ShowScale |> DynObj.setValueOpt histogram2DContour "showscale" + ReverseScale |> DynObj.setValueOpt histogram2DContour "reversescale" + ZAuto |> DynObj.setValueOpt histogram2DContour "zauto" + ZHoverFormat |> DynObj.setValueOpt histogram2DContour "zhoverformat" + Zmin |> DynObj.setValueOpt histogram2DContour "zmin" + Zmid |> DynObj.setValueOpt histogram2DContour "zmid" + Zmax |> DynObj.setValueOpt histogram2DContour "zmax" + AutoContour |> DynObj.setValueOpt histogram2DContour "autocontour" + Contours |> DynObj.setValueOpt histogram2DContour "contours" + HoverLabel |> DynObj.setValueOpt histogram2DContour "hoverlabel" + NContours |> DynObj.setValueOpt histogram2DContour "ncontours" + XCalendar |> DynObj.setValueOptBy histogram2DContour "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy histogram2DContour "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt histogram2DContour "uirevision" + + histogram2DContour ) diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs index 32f175e93..2db155849 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/DistributionCharts.fs @@ -193,13 +193,13 @@ let histogramContourChart = let x = Array.init n (fun i -> ((step i)**3.) + (0.3 * (normal (rnd) 0. 2.) )) let y = Array.init n (fun i -> ((step i)**6.) + (0.3 * (normal (rnd) 0. 2.) )) [ - Chart.Histogram2dContour (x,y,Line=Line.init(Width=0.)) + Chart.Histogram2DContour (x,y,Line=Line.init(Width=0.)) Chart.Point(x,y,Opacity=0.3) ] |> Chart.combine -let histogram2dChart = +let histogram2DChart = let normal (rnd:System.Random) mu tau = let mutable v1 = 2.0 * rnd.NextDouble() - 1.0 let mutable v2 = 2.0 * rnd.NextDouble() - 1.0 @@ -220,24 +220,24 @@ let histogram2dChart = //---------------------- generate data distributed in x and y direction ---------------------- let x = Array.init n (fun i -> ((step i)**3.) + (0.3 * (normal (rnd) 0. 2.) )) let y = Array.init n (fun i -> ((step i)**6.) + (0.3 * (normal (rnd) 0. 2.) )) - Chart.Histogram2d (x,y) + Chart.Histogram2D (x,y) [] let ``Histogram 2D charts`` = testList "DistributionCharts.Histogram charts" [ testCase "Histo contour data" ( fun () -> - "var data = [{\"type\":\"histogram2dcontour\",\"x\":[-1.566002360265054,-1.833996340961623,-1.0330391275776571,-0.8476993487909306,-0.8471270832604864,-1.021055309868153,-0.5368298779218124,-0.9982579324563884,-0.6367576994858231,-1.433590036163408,-1.3735531103452598" + "var data = [{\"type\":\"histogram2Dcontour\",\"x\":[-1.566002360265054,-1.833996340961623,-1.0330391275776571,-0.8476993487909306,-0.8471270832604864,-1.021055309868153,-0.5368298779218124,-0.9982579324563884,-0.6367576994858231,-1.433590036163408,-1.3735531103452598" |> chartGeneratedContains histogramContourChart ); testCase "Histo contour layout" ( fun () -> emptyLayout histogramContourChart ); - testCase "Histo 2d data" ( fun () -> - "var data = [{\"type\":\"histogram2d\",\"x\":[-1.566002360265054,-1.833996340961623,-1.0330391275776571,-0.8476993487909306,-0.8471270832604864,-1.021055309868153,-0.5368298779218124,-0.9982579324563884,-0.6367576994858231,-1.433590036163408,-1.3735531103452598" - |> chartGeneratedContains histogram2dChart + testCase "Histo 2D data" ( fun () -> + "var data = [{\"type\":\"histogram2D\",\"x\":[-1.566002360265054,-1.833996340961623,-1.0330391275776571,-0.8476993487909306,-0.8471270832604864,-1.021055309868153,-0.5368298779218124,-0.9982579324563884,-0.6367576994858231,-1.433590036163408,-1.3735531103452598" + |> chartGeneratedContains histogram2DChart ); - testCase "Histo 2d layout" ( fun () -> - emptyLayout histogram2dChart + testCase "Histo 2D layout" ( fun () -> + emptyLayout histogram2DChart ); ]