Skip to content

Commit bb5af9c

Browse files
authored
Merge pull request #201 from plotly/carpet
2 parents c5f6fbb + 77230a6 commit bb5af9c

File tree

16 files changed

+1812
-163
lines changed

16 files changed

+1812
-163
lines changed

Plotly.NET.sln

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F
9090
docs\09_2_sankey.fsx = docs\09_2_sankey.fsx
9191
docs\10_0_ternary_line_scatter_plots.fsx = docs\10_0_ternary_line_scatter_plots.fsx
9292
docs\10_1_styling_ternary_layouts.fsx = docs\10_1_styling_ternary_layouts.fsx
93+
docs\11_1_carpet_line_scatter_plots.fsx = docs\11_1_carpet_line_scatter_plots.fsx
94+
docs\11_2_contourcarpet_plots.fsx = docs\11_2_contourcarpet_plots.fsx
9395
docs\_template.fsx = docs\_template.fsx
9496
docs\_template.html = docs\_template.html
9597
docs\_template.ipynb = docs\_template.ipynb

docs/10_0_ternary_line_scatter_plots.fsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ Ternary plots are tools for analyzing compositional data in the three-dimensiona
6060
use `Chart.PointTernary` to create a ternary plot that displays points on a ternary coordinate system:
6161
*)
6262

63-
let ternaryPolar = Chart.PointTernary(a,b,c)
63+
let ternaryPoint = Chart.PointTernary(a,b,c)
6464
(*** condition: ipynb ***)
6565
#if IPYNB
66-
ternaryPolar
66+
ternaryPoint
6767
#endif // IPYNB
6868

6969
(***hide***)
70-
ternaryPolar |> GenericChart.toChartHTML
70+
ternaryPoint |> GenericChart.toChartHTML
7171
(***include-it-raw***)
7272

7373
(**
+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
(**
2+
---
3+
title: Carpet line and scatter plots
4+
category: Carpet Plots
5+
categoryindex: 12
6+
index: 1
7+
---
8+
*)
9+
10+
(*** hide ***)
11+
12+
(*** condition: prepare ***)
13+
#r "nuget: Newtonsoft.JSON, 12.0.3"
14+
#r "nuget: DynamicObj"
15+
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
16+
17+
(*** condition: ipynb ***)
18+
#if IPYNB
19+
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
20+
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
21+
#endif // IPYNB
22+
23+
(**
24+
# Carpet charts
25+
26+
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
27+
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
28+
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
29+
30+
*Summary:* This example shows how to create carpet charts in F#.
31+
32+
let's first create some data for the purpose of creating example charts:
33+
34+
*)
35+
36+
open Plotly.NET
37+
38+
//carpet coordinate data
39+
let a = [4.; 4.; 4.; 4.5; 4.5; 4.5; 5.; 5.; 5.; 6.; 6.; 6.]
40+
let b = [1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.]
41+
let y = [2.; 3.5; 4.; 3.; 4.5; 5.; 5.5; 6.5; 7.5; 8.; 8.5; 10.]
42+
43+
//carpet plot data
44+
let aData = [4.; 5.; 5.; 6.]
45+
let bData = [1.; 1.; 2.; 3.]
46+
let sizes = [5; 10; 15; 20]
47+
48+
(**
49+
A carpet plot is any of a few different specific types of plot. The more common plot referred to as a carpet plot is one that illustrates the interaction between two or more independent variables and one or more dependent variables in a two-dimensional plot.
50+
51+
Besides the ability to incorporate more variables, another feature that distinguishes a carpet plot from an equivalent contour plot or 3D surface plot is that a carpet plot can be used to more accurately interpolate data points.
52+
53+
A conventional carpet plot can capture the interaction of up to three independent variables and three dependent variables and still be easily read and interpolated.
54+
55+
Carpet plots have common applications within areas such as material science for showing elastic modulus in laminates,and within aeronautics.
56+
57+
A carpet plot with two independent variables and one dependent variable is often called a cheater plot for the use of a phantom "cheater" axis instead of the horizontal axis.
58+
59+
(https://en.wikipedia.org/wiki/Carpet_plot)
60+
61+
## Carpet Traces
62+
63+
In plotly, carpet plots are different to all other trace types in the regard that the coordinate system of the carpet is not set on the layout, but is itself a trace.
64+
65+
Use `Chart.Carpet` to define these `coordinate traces`. All carpets have a mandatory identifier, which will be used by other traces to define which carpet coordinate system to use.
66+
*)
67+
68+
let carpet = Chart.Carpet("carpetIdentifier", A = a, B = b, Y = y)
69+
70+
(*** condition: ipynb ***)
71+
#if IPYNB
72+
carpet
73+
#endif // IPYNB
74+
75+
(***hide***)
76+
carpet |> GenericChart.toChartHTML
77+
(***include-it-raw***)
78+
79+
(**
80+
## Carpet point charts
81+
82+
use `Chart.PointCarpet` to create a point plot on the referenced carpet coordinate system:
83+
*)
84+
let carpetPoint =
85+
[
86+
carpet
87+
Chart.PointCarpet(aData,bData,"carpetIdentifier", Name = "Point")
88+
]
89+
|> Chart.combine
90+
91+
(*** condition: ipynb ***)
92+
#if IPYNB
93+
carpetPoint
94+
#endif // IPYNB
95+
96+
(***hide***)
97+
carpetPoint |> GenericChart.toChartHTML
98+
(***include-it-raw***)
99+
100+
(**
101+
## Carpet line charts
102+
103+
use `Chart.LineCarpet` to create a line plot on the referenced carpet coordinate system:
104+
*)
105+
106+
let carpetLine =
107+
[
108+
carpet
109+
Chart.LineCarpet(aData,bData,"carpetIdentifier",Name = "Line")
110+
]
111+
|> Chart.combine
112+
113+
(*** condition: ipynb ***)
114+
#if IPYNB
115+
carpetLine
116+
#endif // IPYNB
117+
118+
(***hide***)
119+
carpetLine |> GenericChart.toChartHTML
120+
(***include-it-raw***)
121+
122+
(**
123+
## Carpet Spline charts
124+
125+
use `Chart.LineCarpet` to create a spline plot on the referenced carpet coordinate system:
126+
*)
127+
128+
let carpetSpline =
129+
[
130+
carpet
131+
Chart.SplineCarpet(aData,bData,"carpetIdentifier",Name = "Spline")
132+
]
133+
|> Chart.combine
134+
135+
(*** condition: ipynb ***)
136+
#if IPYNB
137+
carpetSpline
138+
#endif // IPYNB
139+
140+
(***hide***)
141+
carpetSpline |> GenericChart.toChartHTML
142+
(***include-it-raw***)
143+
144+
(**
145+
## Carpet bubble charts
146+
147+
use `Chart.LineCarpet` to create a bubble plot on the referenced carpet coordinate system:
148+
*)
149+
150+
let carpetBubble =
151+
[
152+
carpet
153+
Chart.BubbleCarpet((Seq.zip3 aData bData sizes),"carpetIdentifier",Name = "Bubble")
154+
]
155+
|> Chart.combine
156+
157+
(*** condition: ipynb ***)
158+
#if IPYNB
159+
carpetBubble
160+
#endif // IPYNB
161+
162+
(***hide***)
163+
carpetBubble |> GenericChart.toChartHTML
164+
(***include-it-raw***)
165+
166+
167+
168+

docs/11_2_contourcarpet_plots.fsx

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
(**
2+
---
3+
title: Contour carpet plots
4+
category: Carpet Plots
5+
categoryindex: 12
6+
index: 2
7+
---
8+
*)
9+
10+
(*** hide ***)
11+
12+
(*** condition: prepare ***)
13+
#r "nuget: Newtonsoft.JSON, 12.0.3"
14+
#r "nuget: DynamicObj"
15+
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
16+
17+
(*** condition: ipynb ***)
18+
#if IPYNB
19+
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
20+
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
21+
#endif // IPYNB
22+
23+
(**
24+
# Contour carpet charts
25+
26+
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
27+
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
28+
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
29+
30+
*Summary:* This example shows how to create contour plots on carpets in F#.
31+
32+
*)
33+
34+
open Plotly.NET
35+
open Plotly.NET.LayoutObjects
36+
37+
let contourCarpet =
38+
[
39+
Chart.Carpet(
40+
"contour",
41+
A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.],
42+
B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.],
43+
X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5],
44+
Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75],
45+
AAxis = LinearAxis.initCarpet(
46+
TickPrefix = "a = ",
47+
Smoothing = 0.,
48+
MinorGridCount = 9,
49+
AxisType = StyleParam.AxisType.Linear
50+
),
51+
BAxis = LinearAxis.initCarpet(
52+
TickPrefix = "b = ",
53+
Smoothing = 0.,
54+
MinorGridCount = 9,
55+
AxisType = StyleParam.AxisType.Linear
56+
)
57+
)
58+
Chart.ContourCarpet(
59+
"contour",
60+
[1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625],
61+
A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3],
62+
B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6]
63+
)
64+
]
65+
|> Chart.combine
66+
67+
(*** condition: ipynb ***)
68+
#if IPYNB
69+
contourCarpet
70+
#endif // IPYNB
71+
72+
(***hide***)
73+
contourCarpet |> GenericChart.toChartHTML
74+
(***include-it-raw***)

src/Plotly.NET/ChartAPI/Chart.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ type Chart =
170170
?MultiOpacity = MultiOpacity,
171171
?Pattern = Pattern,
172172
?Symbol = Symbol ,
173-
?MultiSymbols = MultiSymbols ,
173+
?MultiSymbol = MultiSymbols ,
174174
?OutlierColor = OutlierColor ,
175175
?Maxdisplayed = Maxdisplayed ,
176176
?ReverseScale = ReverseScale ,

0 commit comments

Comments
 (0)