Skip to content

Commit a9de5e4

Browse files
committed
Add smith trace to multi-trace-type grid tests and docs
1 parent 738a0ca commit a9de5e4

File tree

3 files changed

+105
-54
lines changed

3 files changed

+105
-54
lines changed

Diff for: docs/01_2_multiple-charts.fsx

+50-8
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,62 @@ open Plotly.NET.LayoutObjects
252252

253253
let multipleTraceTypesGrid =
254254
[
255-
Chart.Point([1,2; 2,3])
256-
Chart.PointTernary([1,2,3; 2,3,4])
257-
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false)
258-
Chart.Point3D([1,3,2])
259-
Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
255+
Chart.Point([1,2; 2,3], Name = "2D Cartesian")
256+
Chart.Point3D([1,3,2], Name = "3D Cartesian")
257+
Chart.PointPolar([10,20], Name = "Polar")
258+
Chart.PointGeo([1,2], Name = "Geo")
259+
Chart.PointMapbox([1,2], Name = "MapBox") |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
260+
Chart.PointTernary([1,2,3; 2,3,4], Name = "Ternary")
261+
[
262+
Chart.Carpet(
263+
"contour",
264+
A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.],
265+
B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.],
266+
X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5],
267+
Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75],
268+
AAxis = LinearAxis.initCarpet(
269+
TickPrefix = "a = ",
270+
Smoothing = 0.,
271+
MinorGridCount = 9,
272+
AxisType = StyleParam.AxisType.Linear
273+
),
274+
BAxis = LinearAxis.initCarpet(
275+
TickPrefix = "b = ",
276+
Smoothing = 0.,
277+
MinorGridCount = 9,
278+
AxisType = StyleParam.AxisType.Linear
279+
),
280+
Opacity = 0.75
281+
)
282+
Chart.ContourCarpet(
283+
[1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625],
284+
"contour",
285+
A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3],
286+
B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6],
287+
ContourLineColor = Color.fromKeyword White,
288+
ShowContourLabels = true,
289+
ShowScale = false
290+
)
291+
]
292+
|> Chart.combine
293+
Chart.Pie([10;40;50;], Name = "Domain")
294+
Chart.BubbleSmith(
295+
[0.5; 1.; 2.; 3.],
296+
[0.5; 1.; 2.; 3.],
297+
sizes = [10;20;30;40],
298+
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
299+
TextPosition=StyleParam.TextPosition.TopCenter,
300+
Name = "Smith"
301+
)
260302
[
261303
// you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case)
262304
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.]
263-
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
264-
Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
305+
Chart.BoxPlot("y" ,y,Name="Combined 1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
306+
Chart.BoxPlot("y'",y,Name="Combined 2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All);
265307
]
266308
|> Chart.combine
267309
]
268-
|> Chart.Grid(2,3)
310+
|> Chart.Grid(4,3)
269311
|> Chart.withSize(1000,1000)
270312

271313
(*** condition: ipynb ***)

Diff for: src/Plotly.NET/Playground.fsx

-36
Original file line numberDiff line numberDiff line change
@@ -184,39 +184,3 @@ open Plotly.NET
184184

185185
open System
186186
open Plotly.NET
187-
188-
Chart.ScatterSmith(
189-
[0.5; 1.; 2.; 3.],
190-
[0.5; 1.; 2.; 3.],
191-
StyleParam.Mode.Lines_Markers_Text,
192-
MultiText = ["Pretty"; "Cool"; "Plot"; "Huh?"],
193-
TextPosition = StyleParam.TextPosition.TopCenter,
194-
UseDefaults = false
195-
)
196-
|> Chart.show
197-
198-
Chart.PointSmith(
199-
[0.5; 1.; 2.; 3.],
200-
[0.5; 1.; 2.; 3.],
201-
UseDefaults = false
202-
)
203-
|> Chart.show
204-
205-
Chart.LineSmith(
206-
[0.5; 1.; 2.; 3.],
207-
[0.5; 1.; 2.; 3.],
208-
LineDash = StyleParam.DrawingStyle.DashDot,
209-
LineColor = Color.fromKeyword Purple,
210-
UseDefaults = false
211-
)
212-
|> Chart.show
213-
214-
Chart.BubbleSmith(
215-
[0.5; 1.; 2.; 3.],
216-
[0.5; 1.; 2.; 3.],
217-
sizes = [10;20;30;40],
218-
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
219-
TextPosition=StyleParam.TextPosition.TopCenter,
220-
UseDefaults = false
221-
)
222-
|> Chart.show

Diff for: tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs

+55-10
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,65 @@ let singleStackChart =
160160

161161
let multiTraceGrid =
162162
[
163-
Chart.Point([1,2; 2,3], UseDefaults = false)
164-
Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false)
165-
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false)
166-
Chart.Point3D([1,3,2], UseDefaults = false)
167-
Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
163+
Chart.Point([1,2; 2,3], Name = "2D Cartesian", UseDefaults = false)
164+
Chart.Point3D([1,3,2], Name = "3D Cartesian", UseDefaults = false)
165+
Chart.PointPolar([10,20], Name = "Polar", UseDefaults = false)
166+
Chart.PointGeo([1,2], Name = "Geo", UseDefaults = false)
167+
Chart.PointMapbox([1,2], Name = "MapBox", UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
168+
Chart.PointTernary([1,2,3; 2,3,4], Name = "Ternary", UseDefaults = false)
169+
[
170+
Chart.Carpet(
171+
"contour",
172+
A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.],
173+
B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.],
174+
X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5],
175+
Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75],
176+
AAxis = LinearAxis.initCarpet(
177+
TickPrefix = "a = ",
178+
Smoothing = 0.,
179+
MinorGridCount = 9,
180+
AxisType = StyleParam.AxisType.Linear
181+
),
182+
BAxis = LinearAxis.initCarpet(
183+
TickPrefix = "b = ",
184+
Smoothing = 0.,
185+
MinorGridCount = 9,
186+
AxisType = StyleParam.AxisType.Linear
187+
),
188+
UseDefaults = false,
189+
Opacity = 0.75
190+
)
191+
Chart.ContourCarpet(
192+
[1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625],
193+
"contour",
194+
A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3],
195+
B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6],
196+
UseDefaults = false,
197+
ContourLineColor = Color.fromKeyword White,
198+
ShowContourLabels = true,
199+
ShowScale = false
200+
)
201+
]
202+
|> Chart.combine
203+
Chart.Pie([10;40;50;], Name = "Domain", UseDefaults = false)
204+
Chart.BubbleSmith(
205+
[0.5; 1.; 2.; 3.],
206+
[0.5; 1.; 2.; 3.],
207+
sizes = [10;20;30;40],
208+
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
209+
TextPosition=StyleParam.TextPosition.TopCenter,
210+
Name = "Smith",
211+
UseDefaults = false
212+
)
168213
[
169214
// you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case)
170215
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.]
171-
Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false);
172-
Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false);
216+
Chart.BoxPlot("y" ,y,Name="Combined 1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false);
217+
Chart.BoxPlot("y'",y,Name="Combined 2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false);
173218
]
174219
|> Chart.combine
175220
]
176-
|> Chart.Grid(2,3)
221+
|> Chart.Grid(4,3)
177222
|> Chart.withSize(1000,1000)
178223

179224
let multiTraceSingleStack =
@@ -210,11 +255,11 @@ let ``Multicharts and subplots`` =
210255
|> chartGeneratedContains subPlotChart
211256
);
212257
testCase "MultiTrace Subplot grid data" ( fun () ->
213-
"""var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"line":{},"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],"marker":{},"line":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"subplot":"mapbox5"},{"type":"box","name":"bin1","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],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x6","yaxis":"y6"},{"type":"box","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],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x6","yaxis":"y6"}];"""
258+
"""var data = [{"type":"scatter","name":"2D Cartesian","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter3d","name":"3D Cartesian","mode":"markers","x":[1],"y":[3],"z":[2],"marker":{},"line":{},"scene":"scene2"},{"type":"scatterpolar","name":"Polar","mode":"markers","r":[10],"theta":[20],"marker":{},"subplot":"polar3"},{"type":"scattergeo","name":"Geo","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"geo":"geo4"},{"type":"scattermapbox","name":"MapBox","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"subplot":"mapbox5"},{"type":"scatterternary","name":"Ternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"line":{},"subplot":"ternary6"},{"type":"carpet","opacity":0.75,"x":[2.0,3.0,4.0,5.0,2.2,3.1,4.1,5.1,1.5,2.5,3.5,4.5],"y":[1.0,1.4,1.6,1.75,2.0,2.5,2.7,2.75,3.0,3.5,3.7,3.75],"a":[0.0,1.0,2.0,3.0,0.0,1.0,2.0,3.0,0.0,1.0,2.0,3.0],"b":[4.0,4.0,4.0,4.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0],"aaxis":{"type":"linear","tickprefix":"a = ","minorgridcount":9,"smoothing":0.0},"baxis":{"type":"linear","tickprefix":"b = ","minorgridcount":9,"smoothing":0.0},"carpet":"contour","xaxis":"x7","yaxis":"y7"},{"type":"contourcarpet","z":[1.0,1.96,2.56,3.0625,4.0,5.0625,1.0,7.5625,9.0,12.25,15.21,14.0625],"a":[0,1,2,3,0,1,2,3,0,1,2,3],"b":[4,4,4,4,5,5,5,5,6,6,6,6],"line":{"color":"rgba(255, 255, 255, 1.0)"},"showscale":false,"carpet":"contour","contours":{"showlabels":true}},{"type":"pie","name":"Domain","values":[10,40,50],"marker":{"line":{}},"domain":{"row":2,"column":1}},{"type":"scattersmith","name":"Smith","mode":"markers+text","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"text":["one","two","three","four","five","six","seven"],"textposition":"top center","marker":{"size":[10,20,30,40]},"line":{},"subplot":"smith9"},{"type":"box","name":"Combined 1","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],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"},{"type":"box","name":"Combined 2","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],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"}];"""
214259
|> chartGeneratedContains multiTraceGrid
215260
);
216261
testCase "MultiTrace Subplot grid layout" ( fun () ->
217-
"""var layout = {"xaxis":{},"yaxis":{},"ternary2":{"domain":{"row":0,"column":1}},"xaxis3":{},"yaxis3":{},"scene4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"xaxis6":{},"yaxis6":{},"grid":{"rows":2,"columns":3,"pattern":"independent"},"width":1000,"height":1000};"""
262+
"""var layout = {"xaxis":{},"yaxis":{},"scene2":{"domain":{"row":0,"column":1}},"polar3":{"domain":{"row":0,"column":2}},"geo4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"ternary6":{"domain":{"row":1,"column":2}},"xaxis7":{},"yaxis7":{},"smith9":{"domain":{"row":2,"column":2}},"xaxis10":{},"yaxis10":{},"grid":{"rows":4,"columns":3,"pattern":"independent"},"width":1000,"height":1000};"""
218263
|> chartGeneratedContains multiTraceGrid
219264
);
220265
testCase "Single Stack data" ( fun () ->

0 commit comments

Comments
 (0)