Skip to content

Commit 7cad66e

Browse files
authored
Merge pull request #270 from plotly/add-smith
2 parents f18b6bf + a9de5e4 commit 7cad66e

18 files changed

+1882
-186
lines changed

Plotly.NET.sln

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F
107107
docs\10_1_styling_ternary_layouts.fsx = docs\10_1_styling_ternary_layouts.fsx
108108
docs\11_1_carpet_line_scatter_plots.fsx = docs\11_1_carpet_line_scatter_plots.fsx
109109
docs\11_2_contourcarpet_plots.fsx = docs\11_2_contourcarpet_plots.fsx
110+
docs\12_1_smith_line_scatter_plots.fsx = docs\12_1_smith_line_scatter_plots.fsx
110111
docs\_template.fsx = docs\_template.fsx
111112
docs\_template.html = docs\_template.html
112113
docs\_template.ipynb = docs\_template.ipynb

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 ***)
+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
(**
2+
---
3+
title: Smith line and scatter plots
4+
category: Smith Plots
5+
categoryindex: 13
6+
index: 1
7+
---
8+
*)
9+
10+
(*** hide ***)
11+
12+
(*** condition: prepare ***)
13+
#r "nuget: Newtonsoft.JSON, 13.0.1"
14+
#r "nuget: DynamicObj, 1.0.1"
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+
# Smith 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 smith 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+
// real coordinates
39+
let real = [0.5; 1.; 2.; 3.]
40+
41+
// imaginary coordinates
42+
let imaginary = [0.5; 1.; 2.; 3.]
43+
44+
(**
45+
The Smith chart, invented by Phillip H. Smith (1905–1987) and independently by Mizuhashi Tosaku, is a graphical calculator or nomogram designed for electrical and electronics engineers specializing in radio frequency (RF) engineering to assist in solving problems with transmission lines and matching circuits
46+
47+
The Smith chart is a mathematical transformation of the two-dimensional Cartesian complex plane. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. If we are dealing only with impedances with non-negative resistive components, our interest is focused on the area inside the circle.
48+
49+
([Wikipedia](https://en.wikipedia.org/wiki/Smith_chart)).
50+
51+
Still, you can plot any kind of imaginary numbers on this plane.
52+
53+
## point smith charts
54+
55+
use `Chart.PointSmith` to create a chart that displays points on a smith subplot:
56+
*)
57+
58+
let pointSmith = Chart.PointSmith(real,imaginary)
59+
(*** condition: ipynb ***)
60+
#if IPYNB
61+
pointSmith
62+
#endif // IPYNB
63+
64+
(***hide***)
65+
pointSmith |> GenericChart.toChartHTML
66+
(***include-it-raw***)
67+
68+
(**
69+
## line smith charts
70+
71+
use `Chart.LineSmith` to create a plot that displays a line connecting the data on a smith subplot.
72+
73+
This example also changes the styles of the line.
74+
*)
75+
76+
let lineSmith =
77+
Chart.LineSmith(
78+
real,
79+
imaginary,
80+
LineDash = StyleParam.DrawingStyle.DashDot,
81+
LineColor = Color.fromKeyword Purple
82+
)
83+
84+
85+
(*** condition: ipynb ***)
86+
#if IPYNB
87+
lineSmith
88+
#endif // IPYNB
89+
90+
(***hide***)
91+
lineSmith |> GenericChart.toChartHTML
92+
(***include-it-raw***)
93+
94+
(**
95+
## bubble smith charts
96+
97+
use `Chart.BubbleSmith` to create a plot that displays datums on a smith subplot, with an additional 3rd dimension set as the marker size.
98+
99+
As for all other plots above, You can for example add labels to each datum:
100+
*)
101+
102+
let bubbleSmith =
103+
Chart.BubbleSmith(
104+
real,
105+
imaginary,
106+
sizes = [10;20;30;40],
107+
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
108+
TextPosition=StyleParam.TextPosition.TopCenter
109+
)
110+
111+
(*** condition: ipynb ***)
112+
#if IPYNB
113+
bubbleSmith
114+
#endif // IPYNB
115+
116+
(***hide***)
117+
bubbleSmith |> GenericChart.toChartHTML
118+
(***include-it-raw***)

0 commit comments

Comments
 (0)